Fix unintended 'as const' name lookup error (#44311) (#44370)

* Fix logic for methods in isTypeParameterPossiblyReferenced

* Add regression tests

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
This commit is contained in:
Daniel Rosenwasser
2021-06-01 14:55:21 -07:00
committed by GitHub
co-authored by Anders Hejlsberg
parent 28e3e6ff2f
commit e425f573aa
5 changed files with 271 additions and 3 deletions
+5 -3
View File
@@ -15941,8 +15941,7 @@ namespace ts {
}
function maybeTypeParameterReference(node: Node) {
return !(node.kind === SyntaxKind.QualifiedName ||
node.parent.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>node.parent).typeArguments && node === (<TypeReferenceNode>node.parent).typeName ||
return !(node.parent.kind === SyntaxKind.TypeReference && (node.parent as TypeReferenceNode).typeArguments && node === (node.parent as TypeReferenceNode).typeName ||
node.parent.kind === SyntaxKind.ImportType && (node.parent as ImportTypeNode).typeArguments && node === (node.parent as ImportTypeNode).qualifier);
}
@@ -15971,7 +15970,10 @@ namespace ts {
return true;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
return (!(node as FunctionLikeDeclaration).type && !!(node as FunctionLikeDeclaration).body) || !!forEachChild(node, containsReference);
return !(node as FunctionLikeDeclaration).type && !!(node as FunctionLikeDeclaration).body ||
some((node as FunctionLikeDeclaration).typeParameters, containsReference) ||
some((node as FunctionLikeDeclaration).parameters, containsReference) ||
!!(node as FunctionLikeDeclaration).type && containsReference((node as FunctionLikeDeclaration).type!);
}
return !!forEachChild(node, containsReference);
}