Skip to content

Allow type-only namespace imports in implements clauses #36464

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
merged 3 commits into from
Jan 28, 2020

Conversation

andrewbranch
Copy link
Member

Fixes #36428

@@ -1792,6 +1792,11 @@ namespace ts {
return containerKind === SyntaxKind.InterfaceDeclaration || containerKind === SyntaxKind.TypeLiteral;
}

export function isFirstIdentifierOfImplementsClause(node: Node) {
return node.parent?.parent?.parent?.kind === SyntaxKind.HeritageClause
Copy link
Member

Choose a reason for hiding this comment

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

why does it have to be the first identifier? Why can't it be anywhere?

(That long chain of ?.s gives me the shivers.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this is a hot path and any other location in the node will be covered by other criteria of isValidTypeOnlyAliasUseSite, so it doesn’t make sense to check more than necessary.

node could be an identifier at the top level of a SourceFile, so I think that’d be SourceFile > ExpressionStatement > Identifier, so I guess only the last ?. is needed.

Copy link
Member

Choose a reason for hiding this comment

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

Also I don't think it checks the scenario of type ? types.SomeInterfaceContainingNamespace.Component since its parent is going to be one more level up than just types.Component ?

Copy link
Member Author

@andrewbranch andrewbranch Jan 27, 2020

Choose a reason for hiding this comment

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

any other location in the node will be covered by other criteria of isValidTypeOnlyAliasUseSite,

double checking that this is true

Copy link
Member Author

Choose a reason for hiding this comment

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

@sheetalkamat this only gets called on identifiers from resolveName, which will only be the left-most identifier. The other parts of entity names get checked elsewhere.

@andrewbranch andrewbranch merged commit 1bb6ea0 into microsoft:master Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'import type * as namespace' no longer can be used with 'implements'
4 participants