docs: add missing package.json "type": "module" step to TypeScript in… - #2464
Open
jnzlab wants to merge 1 commit into
Open
docs: add missing package.json "type": "module" step to TypeScript in…#2464jnzlab wants to merge 1 commit into
jnzlab wants to merge 1 commit into
Conversation
…stall guide The TypeScript setup section provides a tsconfig.json using "module": "nodenext" and demonstrates ESM import syntax in src/app.ts, but doesn't mention that package.json also needs "type": "module" set. Without it, TypeScript treats .ts files as CommonJS by default and throws ECMAScript imports and exports cannot be written in a CommonJS file under 'verbatimModuleSyntax'. (ts1295) when following the guide as written. This adds the missing step so the example works out of the box. Signed-off-by: Jameel Ahmad <jameelahmad221b@gmail.com>
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
There is also another problem - while Node.js can detect and run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
The TypeScript setup section provides a
tsconfig.jsonusing"module": "nodenext"and demonstrates ESMimportsyntax insrc/app.ts, but doesn't mention thatpackage.jsonalso needs"type": "module"set. Without it, TypeScript treats.tsfiles as CommonJS by default and throwsECMAScript imports and exports cannot be written in a CommonJS file under 'verbatimModuleSyntax'. (ts1295)when following the guide as written. This adds the missing step so the example works out of the box.Changes
tsconfig.jsonblock explaining that"module": "nodenext"requirespackage.jsonto declare"type": "module"package.jsoncode snippet showing the required fieldType of change