@@ -18813,25 +18813,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1881318813 case SyntaxKind.TypeQuery:
1881418814 const entityName = (node as TypeQueryNode).exprName;
1881518815 const firstIdentifier = getFirstIdentifier(entityName);
18816- const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
18817- const tpDeclaration = tp.symbol.declarations![0]; // There is exactly one declaration, otherwise `containsReference` is not called
18818- let tpScope: Node;
18819- if (tpDeclaration.kind === SyntaxKind.TypeParameter) { // Type parameter is a regular type parameter, e.g. foo<T>
18820- tpScope = tpDeclaration.parent;
18821- }
18822- else if (tp.isThisType) {
18823- // Type parameter is the this type, and its declaration is the class declaration.
18824- tpScope = tpDeclaration;
18825- }
18826- else {
18827- // Type parameter's declaration was unrecognized.
18828- // This could happen if the type parameter comes from e.g. a JSDoc annotation, so we default to returning true.
18829- return true;
18830- }
18831-
18832- if (firstIdentifierSymbol.declarations) {
18833- return some(firstIdentifierSymbol.declarations, idDecl => isNodeDescendantOf(idDecl, tpScope)) ||
18834- some((node as TypeQueryNode).typeArguments, containsReference);
18816+ if (!isThisIdentifier(firstIdentifier)) { // Don't attempt to analyze typeof this.xxx
18817+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
18818+ const tpDeclaration = tp.symbol.declarations![0]; // There is exactly one declaration, otherwise `containsReference` is not called
18819+ const tpScope = tpDeclaration.kind === SyntaxKind.TypeParameter ? tpDeclaration.parent : // Type parameter is a regular type parameter, e.g. foo<T>
18820+ tp.isThisType ? tpDeclaration : // Type parameter is the this type, and its declaration is the class declaration.
18821+ undefined; // Type parameter's declaration was unrecognized, e.g. comes from JSDoc annotation.
18822+ if (firstIdentifierSymbol.declarations && tpScope) {
18823+ return some(firstIdentifierSymbol.declarations, idDecl => isNodeDescendantOf(idDecl, tpScope)) ||
18824+ some((node as TypeQueryNode).typeArguments, containsReference);
18825+ }
1883518826 }
1883618827 return true;
1883718828 case SyntaxKind.MethodDeclaration:
0 commit comments