From e584243d60f12a76c98c485c9cfa204efce6ade9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 3 Apr 2018 09:04:24 -0700 Subject: [PATCH] Only look up identifiers that could actually be type parameters --- src/compiler/checker.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1e6a16aa75f..2e4937c95aa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9106,6 +9106,11 @@ namespace ts { return type; } + function maybeTypeParameterReference(node: Node) { + return !(node.kind === SyntaxKind.QualifiedName || + node.parent.kind === SyntaxKind.TypeReference && (node.parent).typeArguments && node === (node.parent).typeName); + } + function isTypeParameterPossiblyReferenced(tp: TypeParameter, node: Node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks // between the node and the type parameter declaration, if the node contains actual references to the @@ -9122,7 +9127,8 @@ namespace ts { case SyntaxKind.ThisType: return tp.isThisType; case SyntaxKind.Identifier: - return !tp.isThisType && isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp; + return !tp.isThisType && isPartOfTypeNode(node) && maybeTypeParameterReference(node) && + getTypeFromTypeNode(node) === tp; case SyntaxKind.TypeQuery: return true; }