-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Allow import assertions on esm imports under module: nodenext #46630
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
Allow import assertions on esm imports under module: nodenext #46630
Conversation
src/compiler/diagnosticMessages.json
Outdated
@@ -3353,6 +3353,10 @@ | |||
"category": "Error", | |||
"code": 2835 | |||
}, | |||
"Import assertions are not allowed on statements that transpile to commonjs require calls.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Import assertions are not allowed on statements that transpile to commonjs require calls.": { | |
"Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.": { |
tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt
Outdated
Show resolved
Hide resolved
tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As someone who doesn't know that much about modules and import assertions, the error message that says "Import assertions are not allowed on statements that transpile to commonjs 'require' calls" looks a bit puzzling, even though it's accurate. But I don't know how that could be improved; maybe instead of saying "statements that transpile to CommonJs..." we could explicitly list the scenarios when this is true? That might be too verbose and not helpful either...
Otherwise this looks good.
@typescript-bot cherry-pick this to release-4.5 |
Heya @andrewbranch, I've started to run the task to cherry-pick this into |
Hey @andrewbranch, I've opened #46648 for you. |
I think "import declarations and external reexport declarations in a cjs mode file except for dynamic import expressions" is a bit of a mouthful. And probably not much better. |
…oft#46630) * Allow import assertions on esm imports under module: nodenext * Changes to copy Co-authored-by: Andrew Branch <[email protected]>
Fixes #46372