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

Flag default imports with named imports as needing importStar #23795

Merged

Conversation

weswigham
Copy link
Member

Fixes #21621

@weswigham weswigham requested review from rbuckton and mhegazy April 30, 2018 22:58
@@ -34,7 +34,8 @@ namespace ts {
}

export function getImportNeedsImportStarHelper(node: ImportDeclaration) {
return !!getNamespaceDeclarationNode(node) || (getNamedImportCount(node) > 1 && containsDefaultReference(node.importClause.namedBindings));
const minNamed = isDefaultImport(node) ? 0 : 1;
return !!getNamespaceDeclarationNode(node) || (getNamedImportCount(node) > minNamed && (!minNamed || containsDefaultReference(node.importClause.namedBindings)));
Copy link
Contributor

Choose a reason for hiding this comment

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

this assumes that default will only appear at most once in the named list, but nothing stops you from writing import {default as a, default as b} from "m";. which should be harmless. but worth adding a test.

@weswigham
Copy link
Member Author

@mhegazy I've restructured the helper functions a bit and added your testcase, you should re-review.

@weswigham weswigham merged commit b5b7fc4 into microsoft:master May 2, 2018
@weswigham weswigham deleted the use-export-star-when-more-than-default branch May 2, 2018 23:20
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants