@@ -18837,25 +18837,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
18837
18837
case SyntaxKind.TypeQuery:
18838
18838
const entityName = (node as TypeQueryNode).exprName;
18839
18839
const firstIdentifier = getFirstIdentifier(entityName);
18840
- const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
18841
- const tpDeclaration = tp.symbol.declarations![0]; // There is exactly one declaration, otherwise `containsReference` is not called
18842
- let tpScope: Node;
18843
- if (tpDeclaration.kind === SyntaxKind.TypeParameter) { // Type parameter is a regular type parameter, e.g. foo<T>
18844
- tpScope = tpDeclaration.parent;
18845
- }
18846
- else if (tp.isThisType) {
18847
- // Type parameter is the this type, and its declaration is the class declaration.
18848
- tpScope = tpDeclaration;
18849
- }
18850
- else {
18851
- // Type parameter's declaration was unrecognized.
18852
- // This could happen if the type parameter comes from e.g. a JSDoc annotation, so we default to returning true.
18853
- return true;
18854
- }
18855
-
18856
- if (firstIdentifierSymbol.declarations) {
18857
- return some(firstIdentifierSymbol.declarations, idDecl => isNodeDescendantOf(idDecl, tpScope)) ||
18858
- some((node as TypeQueryNode).typeArguments, containsReference);
18840
+ if (!isThisIdentifier(firstIdentifier)) { // Don't attempt to analyze typeof this.xxx
18841
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
18842
+ const tpDeclaration = tp.symbol.declarations![0]; // There is exactly one declaration, otherwise `containsReference` is not called
18843
+ const tpScope = tpDeclaration.kind === SyntaxKind.TypeParameter ? tpDeclaration.parent : // Type parameter is a regular type parameter, e.g. foo<T>
18844
+ tp.isThisType ? tpDeclaration : // Type parameter is the this type, and its declaration is the class declaration.
18845
+ undefined; // Type parameter's declaration was unrecognized, e.g. comes from JSDoc annotation.
18846
+ if (firstIdentifierSymbol.declarations && tpScope) {
18847
+ return some(firstIdentifierSymbol.declarations, idDecl => isNodeDescendantOf(idDecl, tpScope)) ||
18848
+ some((node as TypeQueryNode).typeArguments, containsReference);
18849
+ }
18859
18850
}
18860
18851
return true;
18861
18852
case SyntaxKind.MethodDeclaration:
0 commit comments