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

"module": "node16" gives contradictory error about import assertions #50653

Closed
kidonng opened this issue Sep 6, 2022 · 3 comments Β· Fixed by #50673
Closed

"module": "node16" gives contradictory error about import assertions #50653

kidonng opened this issue Sep 6, 2022 · 3 comments Β· Fixed by #50673
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@kidonng
Copy link

kidonng commented Sep 6, 2022

Bug Report

πŸ”Ž Search Terms

module node16 import assertions

πŸ•— Version & Regression Information

Happened in 4.8.2, also 4.7.4 and 4.8 beta in playground.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const file = "foo.json"
const test = await import(file, {assert: {type: 'json'}})
export {}

πŸ™ Actual behavior

Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.

πŸ™‚ Expected behavior

No error

@andrewbranch
Copy link
Member

This is not a TypeScript issue, but a Playground issueβ€”so while the symptom is slightly different, it’s a duplicate of #49842. Until fixed, you have to refresh the playground page after switching module πŸ˜•

@andrewbranch andrewbranch added the Duplicate An existing issue was already created label Sep 6, 2022
@fatcerberus
Copy link

fatcerberus commented Sep 6, 2022

@andrewbranch Still repros after setting Module to Node16 and refreshing. Changing to NodeNext and refreshing makes the error go away. So this does seem to be as described, node16 doesn’t support dynamic import assertions, in contradiction of the error message.

@andrewbranch andrewbranch added Bug A bug in TypeScript and removed Duplicate An existing issue was already created labels Sep 6, 2022
@andrewbranch andrewbranch added this to the TypeScript 4.9.0 milestone Sep 6, 2022
@kidonng
Copy link
Author

kidonng commented Sep 7, 2022

Sorry, I really should have stated this also happens locally:

image

I noticed the Playground has some funky issues, but I assume you already know abou that.

@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Sep 7, 2022
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.

5 participants