mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-23 18:48:40 -05:00
Only look up identifiers that could actually be type parameters
This commit is contained in:
committed by
Mohamed Hegazy
parent
2be103a200
commit
66adcc3f7a
@@ -8978,6 +8978,11 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
function maybeTypeParameterReference(node: Node) {
|
||||
return !(node.kind === SyntaxKind.QualifiedName ||
|
||||
node.parent.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>node.parent).typeArguments && node === (<TypeReferenceNode>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(<TypeNode>node) === tp;
|
||||
return !tp.isThisType && isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
|
||||
getTypeFromTypeNode(<TypeNode>node) === tp;
|
||||
case SyntaxKind.TypeQuery:
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user