Repository navigation
Provide more information when there is a SyntaxError #56830
Description
Activity
99% of the time is because you are importing a type or interface without the
typekeyword.
Amaro has nothing to do with it.
This is not a parsing error which is all amaro does.
Check in your code where you are importingTransactionand change it totype Transaction@JakobJingleheimer can your codemod fix this?
Yes the solution is quite easy and not hard to fix. My point of the issue is that why is this syntax error not stating which file the issue is coming from? If its not amaro, would this be a Node.js loader thing? Where might the best place for this issue be?
Here is another example:
SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]: x TypeScript parameter property is not supported in strip-only mode ,-[141:1] 138 | sessionResolve: Function; 139 | sessionReject: Function; 140 | constructor( 141 | public url: string, : ^^^^^^^^^^^ 142 | public subscription: any, 143 | public databaseName: string, 144 | public nodeName?: string, `---- x TypeScript parameter property is not supported in strip-only mode ,-[142:1] 139 | sessionReject: Function; 140 | constructor( 141 | public url: string, 142 | public subscription: any, : ^^^^^^^^^^^^^^^^^ 143 | public databaseName: string, 144 | public nodeName?: string, 145 | public authorization?: string `---- x TypeScript parameter property is not supported in strip-only mode ,-[143:1] 140 | constructor( 141 | public url: string, 142 | public subscription: any, 143 | public databaseName: string, : ^^^^^^^^^^^^^^^^^^^^ 144 | public nodeName?: string, 145 | public authorization?: string 146 | ) { `---- x TypeScript parameter property is not supported in strip-only mode ,-[144:1] 141 | public url: string, 142 | public subscription: any, 143 | public databaseName: string, 144 | public nodeName?: string, : ^^^^^^^^^^^^^^^^^ 145 | public authorization?: string 146 | ) { 147 | super(); `---- x TypeScript parameter property is not supported in strip-only mode ,-[145:1] 142 | public subscription: any, 143 | public databaseName: string, 144 | public nodeName?: string, 145 | public authorization?: string : ^^^^^^^^^^^^^^^^^^^^^^ 146 | ) { 147 | super(); 148 | this.nodeName = this.nodeName ?? urlToNodeName(url); `---- at parseTypeScript (node:internal/modules/typescript:52:11) at processTypeScriptCode (node:internal/modules/typescript:98:42) at stripTypeScriptModuleTypes (node:internal/modules/typescript:132:10) at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:146:26) at defaultGetFormat (node:internal/modules/esm/get_format:209:36) at defaultLoadSync (node:internal/modules/esm/load:176:14) at #loadAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:751:12) at #loadSync (node:internal/modules/esm/loader:773:49) at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:412:38) at new ModuleJobSync (node:internal/modules/esm/module_job:342:34) { code: 'ERR_INVALID_TYPESCRIPT_SYNTAX' }Like yes I can search-replace here to find where these are, but also its a bit of a chore (and can be misleading) in a large code base. I'd rather these errors just contain the file path at least.
Here is another example:
SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]: x TypeScript parameter property is not supported in strip-only mode ,-[141:1] 138 | sessionResolve: Function; 139 | sessionReject: Function; 140 | constructor( 141 | public url: string, : ^^^^^^^^^^^ 142 | public subscription: any, 143 | public databaseName: string, 144 | public nodeName?: string, `---- x TypeScript parameter property is not supported in strip-only mode ,-[142:1] 139 | sessionReject: Function; 140 | constructor( 141 | public url: string, 142 | public subscription: any, : ^^^^^^^^^^^^^^^^^ 143 | public databaseName: string, 144 | public nodeName?: string, 145 | public authorization?: string `---- x TypeScript parameter property is not supported in strip-only mode ,-[143:1] 140 | constructor( 141 | public url: string, 142 | public subscription: any, 143 | public databaseName: string, : ^^^^^^^^^^^^^^^^^^^^ 144 | public nodeName?: string, 145 | public authorization?: string 146 | ) { `---- x TypeScript parameter property is not supported in strip-only mode ,-[144:1] 141 | public url: string, 142 | public subscription: any, 143 | public databaseName: string, 144 | public nodeName?: string, : ^^^^^^^^^^^^^^^^^ 145 | public authorization?: string 146 | ) { 147 | super(); `---- x TypeScript parameter property is not supported in strip-only mode ,-[145:1] 142 | public subscription: any, 143 | public databaseName: string, 144 | public nodeName?: string, 145 | public authorization?: string : ^^^^^^^^^^^^^^^^^^^^^^ 146 | ) { 147 | super(); 148 | this.nodeName = this.nodeName ?? urlToNodeName(url); `---- at parseTypeScript (node:internal/modules/typescript:52:11) at processTypeScriptCode (node:internal/modules/typescript:98:42) at stripTypeScriptModuleTypes (node:internal/modules/typescript:132:10) at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:146:26) at defaultGetFormat (node:internal/modules/esm/get_format:209:36) at defaultLoadSync (node:internal/modules/esm/load:176:14) at #loadAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:751:12) at #loadSync (node:internal/modules/esm/loader:773:49) at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:412:38) at new ModuleJobSync (node:internal/modules/esm/module_job:342:34) { code: 'ERR_INVALID_TYPESCRIPT_SYNTAX' }Like yes I can search-replace here to find where these are, but also its a bit of a chore (and can be misleading) in a large code base. I'd rather these errors just contain the file path at least.
Yeah those are node core issues, we might have to trim the stacktrace. Amaro just throws an errors, the caller (Node) is responsible for stacktrace.
99% of the time is because you are importing a type or interface without the
typekeyword.
Amaro has nothing to do with it.
This is not a parsing error which is all amaro does.
Check in your code where you are importingTransactionand change it totype Transaction@JakobJingleheimer can your codemod fix this?
Yes, I think so
https://github.com/nodejs/userland-migrations/tree/main/recipes/correct-ts-specifiers
The publication to codemod is not quite working yet, but you can run it via node like
$ node path/to/correct-ts-specifiers/src/workflow.tsYou'll need to install correct-ts-specifiers' deps
Here is another example:
SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]: x TypeScript parameter property is not supported in strip-only mode ,-[141:1] 138 | sessionResolve: Function; 139 | sessionReject: Function; 140 | constructor( 141 | public url: string, : ^^^^^^^^^^^ 142 | public subscription: any, 143 | public databaseName: string, 144 | public nodeName?: string,For this, you need a different userland-migration (currently WIP): nodejs/userland-migrations#21
Also typechecker should warn you if you use verbatimModuleSyntax
- changed the title
[-]Feedback: Provide more information when there is a SyntaxError[/-][+]Provide more information when there is a SyntaxError[/+]on Jan 30, 2025 Moving this issue to nodejs/node, it refs swc-project/swc#9884.
I'm planning to include the location in the file where the error is generated.- addedstrip-typesIssues and PRs related to TypeScript type stripping.Issues and PRs related to TypeScript type stripping.
on Jan 30, 2025 This PR will fix the issue #57598 as the filename and line will be correctly included in the error
- added a commit that references this issue
on Apr 1, 2025 - added a commit that references this issue
on Apr 1, 2025 1 remaining item
- added 2 commits that reference this issue
on Jul 15, 2025
I'm working on migrating a large JS/TS repo to using Node.js v23 type-stripping. I've already applied some codemods to transform requires & imports, as well as remove TS specific syntax. I'm now running into some syntax errors regarding missing exports which I think were silently being ignored previously. The error does not say what file it is coming from and that is proving difficult to track down. Can amaro print that info? Thank you!
For example: