-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
@@ -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 |
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.
why does it have to be the first identifier? Why can't it be anywhere?
(That long chain of ?.
s gives me the shivers.)
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.
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.
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.
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
?
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.
any other location in the node will be covered by other criteria of isValidTypeOnlyAliasUseSite,
double checking that this is true
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.
@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.
Fixes #36428