Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get error with typescript 5 #19

Closed
agrozyme opened this issue Mar 28, 2023 · 4 comments · Fixed by #20
Closed

get error with typescript 5 #19

agrozyme opened this issue Mar 28, 2023 · 4 comments · Fixed by #20

Comments

@agrozyme
Copy link

When I use typescript 5, I get the error in compiler mjs (cjs is ok):
Error: Debug Failure. Unhandled SyntaxKind: ImportClause.

This setting is ok when I use typescript 4
(only get wran: DeprecationWarning: 'createImportDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.)

tsc-multi.json

{
  "targets": [
    { "extname": ".mjs", "module": "ESNext", "moduleResolution": "NodeNext" },
    { "extname": ".js", "module": "CommonJS", "moduleResolution": "Node" }
  ],
  "projects": ["."]
}

milesrichardson added a commit to splitgraph/madatdata that referenced this issue Mar 28, 2023
…roken

Need to make some decisions about whether/how to emit CJS modules,
because as long as we have verbatimModuleSyntax enabled, we cannot
use the typical `export const = "x"` format, and tsc-multi rewriting
is also now breaking for this on v5, and patching it to do the rewrites
may be non trivial since it can involve shifting large blocks of code.

Alternatively we could just not opt into the flag, in which case
we should also restore the `isolatedModules` flag (which was removed
as redunant).

See:

* https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#verbatimmodulesyntax
* microsoft/TypeScript#52203
* tommy351/tsc-multi#19
@milesrichardson
Copy link

I'm seeing the same, although I'm not sure if it's limited to particular target or module or extname (I tried simplifying by including only {"target": "esnext", "module": "esnext", "extname": ".mjs"} and still got the error, but this could also be related to one of the many .tsconfig.*.json files in my codebase).

Given the changes in TS5.0 to verbatimModuleSyntax, which tbh I find extremely confusing, I am considering abandoning CJS as a build target. Then I won't need tsc-multi because its rewriting tricks won't be necessary, although I will instead need to manually update all imports to include extensions, and will also need to add some new tsconfig.*.json files to each package.

That said, I do love this little tool. It made my configs a lot more DRY and saved me from writing some hacky build scripts.

@tommy351
Copy link
Owner

I think the reason is the function signature changes of ts.factory.createImportDeclaration and ts.factory.createExportDeclaration in TypeScript 5.0. This issue will be fixed later.

Commit: 20d7e26

@tommy351
Copy link
Owner

tommy351 commented Apr 1, 2023

[email protected] released.

milesrichardson added a commit to splitgraph/madatdata that referenced this issue Apr 10, 2023
…roken

Need to make some decisions about whether/how to emit CJS modules,
because as long as we have verbatimModuleSyntax enabled, we cannot
use the typical `export const = "x"` format, and tsc-multi rewriting
is also now breaking for this on v5, and patching it to do the rewrites
may be non trivial since it can involve shifting large blocks of code.

Alternatively we could just not opt into the flag, in which case
we should also restore the `isolatedModules` flag (which was removed
as redunant).

See:

* https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#verbatimmodulesyntax
* microsoft/TypeScript#52203
* tommy351/tsc-multi#19
@milesrichardson
Copy link

Works great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants