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

Refactor named imports to default instead of namespace when esModuleInterop is on and module is an export= #47744

Merged
merged 1 commit into from
Feb 5, 2022

Conversation

andrewbranch
Copy link
Member

If a module declares an export =, we let you import the resolved export’s members with named imports, but this is generally asking for a bad time. If you have esModuleInterop enabled, the best thing to do with an export = is to default-import it. However, the refactor we offer is to convert the named imports to a namespace (import *) import. That’s definitely the most correct translation from named imports, but if you were already doing something super sketchy by using named imports, we can nudge you in the direction of doing something better by replacing them with a default import instead a namespace import.

Closes #46047

@sandersn
Copy link
Member

sandersn commented Feb 5, 2022

If a module declares an export =, we let you import the resolved export’s members with named imports, but this is generally asking for a bad time

I have only ever had a good time doing this.

@andrewbranch
Copy link
Member Author

That's because you like to avoid classes

@andrewbranch andrewbranch merged commit 9c3b41d into microsoft:main Feb 5, 2022
@andrewbranch andrewbranch deleted the feature/46047 branch February 5, 2022 01:11
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.

Please add a new "Convert to bound imports" TS refactoring
3 participants