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

Typescript 4.5 resolveJsonModule should also work with node12 and nodenext module and resolveTypes #46362

Closed
frank-dspeed opened this issue Oct 14, 2021 · 2 comments Β· Fixed by #46434
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@frank-dspeed
Copy link

frank-dspeed commented Oct 14, 2021

Bug Report

πŸ”Ž Search Terms

resolveJsonModule typescript 4.5 node node12 nodenext

πŸ•— Version & Regression Information

4.5 +

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

set resolveJsonModule true and moduleResolution node12 or nodenext in the tsconfig.json

πŸ™ Actual behavior

Errors

TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.

πŸ™‚ Expected behavior

should work with node12 and nodenext also

@andrewbranch andrewbranch added the Bug A bug in TypeScript label Oct 15, 2021
@andrewbranch andrewbranch added this to the TypeScript 4.5.1 milestone Oct 15, 2021
@weswigham
Copy link
Member

JSON imports in esm mode imports at least are still experimental and need a flag, and there's a big kerfuffle over on the node repo as to weather they should require an assert { type: "json" } on the import (see conversations on nodejs/node#37375 and nodejs/node#40250 ). We can allow it for cjs mode imports pretty painlessly, but for esm imports it's still experimental, unfortunately (and not having any named imports is unfortunately going to be a big change from current behavior, too). So the fix for this might not take the shape you're expecting.

@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Oct 19, 2021
@frank-dspeed
Copy link
Author

frank-dspeed commented Oct 20, 2021

@weswigham we use it only for typechecking inside our project https://github.com/rollup/rollup/blob/master/rollup.config.ts

we extract the version fild of the package.json.

also there are .cjs files possible in case of node12 and nodenext where it should be painless to allow it so allow it in general is fine. As there are also none node environments that are working with .mjs and cjs it is fine to enable it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants