From 66adcc3f7a51dc5e7fee8805a7a3788db9969276 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 4e8f5fbf966..3a40b72d3b0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8978,6 +8978,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 @@ -8994,7 +8999,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; }