Skip to content

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

Merged

Conversation

weswigham
Copy link
Member

Fixes #46372

@@ -3353,6 +3353,10 @@
"category": "Error",
"code": 2835
},
"Import assertions are not allowed on statements that transpile to commonjs require calls.": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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.": {

Copy link
Member

@gabritto gabritto left a 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.

@andrewbranch
Copy link
Member

@typescript-bot cherry-pick this to release-4.5

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 2, 2021

Heya @andrewbranch, I've started to run the task to cherry-pick this into release-4.5 on this PR at b48868d. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @andrewbranch, I've opened #46648 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Nov 2, 2021
Component commits:
8ba5d7c Allow import assertions on esm imports under module: nodenext

2c5b9a9 Changes to copy

b48868d Merge branch 'main' into import-assertions-module-nodenext
@weswigham
Copy link
Member Author

could explicitly list the scenarios when this is true?

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.

@weswigham weswigham merged commit de23842 into microsoft:main Nov 2, 2021
andrewbranch added a commit to typescript-bot/TypeScript that referenced this pull request Nov 3, 2021
Component commits:
8ba5d7c Allow import assertions on esm imports under module: nodenext

2c5b9a9 Changes to copy

b48868d Merge branch 'main' into import-assertions-module-nodenext
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
…oft#46630)

* Allow import assertions on esm imports under module: nodenext

* Changes to copy

Co-authored-by: Andrew Branch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import assertions not allowed in nodenext
4 participants