@@ -2388,6 +2388,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
23882388 var comparableRelation = new Map<string, RelationComparisonResult>();
23892389 var identityRelation = new Map<string, RelationComparisonResult>();
23902390 var enumRelation = new Map<string, RelationComparisonResult>();
2391+ var relationOverflowed = false;
23912392
23922393 // Extensions suggested for path imports when module resolution is node16 or higher.
23932394 // The first element of each tuple is the extension a file has.
@@ -22412,6 +22413,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2241222413 reportIncompatibleStack();
2241322414 }
2241422415 if (overflow) {
22416+ relationOverflowed = true;
2241522417 // Record this relation as having failed such that we don't attempt the overflowing operation again.
2241622418 const id = getRelationKey(source, target, /*intersectionState*/ IntersectionState.None, relation, /*ignoreConstraints*/ false);
2241722419 relation.set(id, RelationComparisonResult.Failed | (relationCount <= 0 ? RelationComparisonResult.ComplexityOverflow : RelationComparisonResult.StackDepthOverflow));
@@ -36539,7 +36541,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3653936541 const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
3654036542 const isJsxOpenFragment = isJsxOpeningFragment(node);
3654136543 const isInstanceof = node.kind === SyntaxKind.BinaryExpression;
36542- const reportErrors = !isInferencePartiallyBlocked && !candidatesOutArray;
36544+ let reportErrors = !isInferencePartiallyBlocked && !candidatesOutArray;
3654336545
3654436546 // The following variables are captured and modified by calls to chooseOverload.
3654536547 // If overload resolution or type argument inference fails, we want to report the
@@ -36612,6 +36614,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3661236614 // If we are in signature help, a trailing comma indicates that we intend to provide another argument,
3661336615 // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments.
3661436616 const signatureHelpTrailingComma = !!(checkMode & CheckMode.IsForSignatureHelp) && node.kind === SyntaxKind.CallExpression && node.arguments.hasTrailingComma;
36617+ const saveRelationOverflowed = relationOverflowed;
36618+ relationOverflowed = false;
3661536619
3661636620 // Section 4.12.1:
3661736621 // if the candidate list contains one or more signatures for which the type of each argument
@@ -36629,6 +36633,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3662936633 if (!result) {
3663036634 result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
3663136635 }
36636+ // Disable error reporting if relation overflowed during the overload resolution given the oveflow error was already reported.
36637+ // By attempting to report the error below the overflow could not happen again (given some of the caches would already be populated)
36638+ // and the compiler would crash with "No error for last overload signature".
36639+ reportErrors &&= !relationOverflowed;
36640+ relationOverflowed = saveRelationOverflowed;
36641+
3663236642 const links = getNodeLinks(node);
3663336643 if (links.resolvedSignature !== resolvingSignature && !candidatesOutArray) {
3663436644 // There are 2 situations in which it's good to preemptively return the cached result here:
0 commit comments