@@ -6167,7 +6167,7 @@ namespace ts {
6167
6167
export function isValidTypeOnlyAliasUseSite ( useSite : Node ) : boolean {
6168
6168
return ! ! ( useSite . flags & NodeFlags . Ambient )
6169
6169
|| isPartOfTypeQuery ( useSite )
6170
- || isFirstIdentifierOfNonEmittingHeritageClause ( useSite )
6170
+ || isIdentifierInNonEmittingHeritageClause ( useSite )
6171
6171
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName ( useSite )
6172
6172
|| ! isExpressionNode ( useSite ) ;
6173
6173
}
@@ -6190,10 +6190,20 @@ namespace ts {
6190
6190
return containerKind === SyntaxKind . InterfaceDeclaration || containerKind === SyntaxKind . TypeLiteral ;
6191
6191
}
6192
6192
6193
- /** Returns true for the first identifier of 1) an `implements` clause, and 2) an `extends` clause of an interface. */
6194
- function isFirstIdentifierOfNonEmittingHeritageClause ( node : Node ) : boolean {
6195
- // Number of parents to climb from identifier is 2 for `implements I`, 3 for `implements x.I`
6196
- const heritageClause = tryCast ( node . parent . parent , isHeritageClause ) ?? tryCast ( node . parent . parent ?. parent , isHeritageClause ) ;
6193
+ /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */
6194
+ function isIdentifierInNonEmittingHeritageClause ( node : Node ) : boolean {
6195
+ if ( node . kind !== SyntaxKind . Identifier ) return false ;
6196
+ const heritageClause = findAncestor ( node . parent , parent => {
6197
+ switch ( parent . kind ) {
6198
+ case SyntaxKind . HeritageClause :
6199
+ return true ;
6200
+ case SyntaxKind . PropertyAccessExpression :
6201
+ case SyntaxKind . ExpressionWithTypeArguments :
6202
+ return false ;
6203
+ default :
6204
+ return "quit" ;
6205
+ }
6206
+ } ) as HeritageClause | undefined ;
6197
6207
return heritageClause ?. token === SyntaxKind . ImplementsKeyword || heritageClause ?. parent . kind === SyntaxKind . InterfaceDeclaration ;
6198
6208
}
6199
6209
}
0 commit comments