Defer processing of nested generic calls that return constructor types (#54813)

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
Mateusz Burzyński
2023-11-30 11:24:04 -08:00
committed by GitHub
co-authored by Nathan Shively-Sanders
parent eb2046d046
commit 8d1fa440dd
4 changed files with 170 additions and 3 deletions
+7 -3
View File
@@ -34776,7 +34776,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// use the resolvingSignature singleton to indicate that we deferred processing. This result will be
// propagated out and eventually turned into silentNeverType (a type that is assignable to anything and
// from which we never make inferences).
if (checkMode & CheckMode.SkipGenericFunctions && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
if (checkMode & CheckMode.SkipGenericFunctions && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
skippedGenericFunction(node, checkMode);
return resolvingSignature;
}
@@ -34789,8 +34789,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
}
function isGenericFunctionReturningFunction(signature: Signature) {
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
function isGenericFunctionReturningFunctionOrConstructor(signature: Signature) {
if (!signature.typeParameters) {
return false;
}
const returnType = getReturnTypeOfSignature(signature);
return isFunctionType(returnType) || isConstructorType(returnType);
}
/**