-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
TS5071 error fires when using mode="esnext", but builds were fine before 3.0.1 #26224
Comments
my code originally looked like this and it worked:
The error fired, and if I ignored the error,
baseConfig then was imported correctly. But it broke import statements for other dependencies, like AWS:
Why was this error introduced to begin with? |
I have the same problem - this error is not listed in breaking changes: So I think it should be changed as TS 2.9.1 worked well with |
This is duplicate of #25755 |
--resolveJsonModule is supported only when using nodejs module resolution and emit is commonjs. In other systems json module is not supported natively without any plugins and hence the error. The check for emit was missing earlier rather than intentional allowing it (so your code was always error but we missed on reporting errors on it before) |
I get it but I have the same problem as #25755 (comment) - webpack + esnext = tree shaking, so I can't switch to |
@sheetalkamat If my code functioned correctly before this error check was implemented, didn't it technically already support it before this error check existed? Theres nothing funky with my code, it's standard syntax (just with allowSyntheticDefaultImports enabled). Why should I be forced to downgrade to commonjs when it was working perfectly fine before? |
@sheetalkamat, any idea how to resolve my json file without the extension? i'm using vscode+typescript.
|
You have to explicitly use .json in the module specifier to be able to resolve to a json module. We have this constraint so that the json files don't get included without intentionally choosing to for those specific module specifiers |
I see. @sheetalkamat thank you :) |
TypeScript Version: 3.0.1
Search Terms:
TS5071
Code
https://github.com/Microsoft/TypeScript/blob/d8cbe34a051a64d39f55f4e46e18ac404aac922e/src/compiler/diagnosticMessages.json#L2887
Expected behavior:
This should work fine with mode="esnext" just like it always did.
Actual behavior:
I've been using the following tsconfig.json file with zero issues before upgrading to 3.0:
{ "compileOnSave": true, "compilerOptions": { "target": "esnext", "module": "esnext", "sourceMap": true, "declaration": true, "declarationDir": "../decl", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "noUnusedLocals": true, "resolveJsonModule": true, "noUnusedParameters": true, "skipLibCheck":true, "outDir":"../dist/", "typeRoots" : ["../node_modules/@types"] }, "exclude":["../node_modules/@types/"] }
Now this error message is firing, but the resolution and import of json files work fine when module is set to esnext. Switching mode to commonjs breaks my import syntax, modules are missing left right and center.
@sheetalkamat, could you help give insight on this?
The text was updated successfully, but these errors were encountered: