narrow type for generic variables inside TypeQuery (#48434)

This commit is contained in:
Zzzen authored and GitHub committed 2022-04-05 09:33:19 -07:00
1 parent 25aecd4c3e
commit 370d34cdca
6 files changed
+222

No files matched your search

+1
View File
@@ -25311,6 +25311,7 @@ namespace ts {
// a generic type without a nullable constraint and x is a generic type. This is because when both obj
// and x are of generic types T and K, we want the resulting type to be T[K].
return parent.kind === SyntaxKind.PropertyAccessExpression ||
parent.kind === SyntaxKind.QualifiedName ||
parent.kind === SyntaxKind.CallExpression && (parent as CallExpression).expression === node ||
parent.kind === SyntaxKind.ElementAccessExpression && (parent as ElementAccessExpression).expression === node &&
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression((parent as ElementAccessExpression).argumentExpression)));