Skip to content

Commit 2e17deb

Browse files
committed
Prefer error candidates with no rest parameters over those with
1 parent 52293ed commit 2e17deb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19453,7 +19453,10 @@ namespace ts {
1945319453
checkCandidate = candidate;
1945419454
}
1945519455
if (!checkApplicableSignature(node, args, checkCandidate, relation, excludeArgument, /*reportErrors*/ false)) {
19456-
candidateForArgumentError = checkCandidate;
19456+
// Give preference to error candidates that have no rest parameters (as they are more specific)
19457+
if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType(checkCandidate)) {
19458+
candidateForArgumentError = checkCandidate;
19459+
}
1945719460
continue;
1945819461
}
1945919462
if (excludeArgument) {
@@ -19466,7 +19469,10 @@ namespace ts {
1946619469
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJavaScriptFile(candidate.declaration));
1946719470
}
1946819471
if (!checkApplicableSignature(node, args, checkCandidate, relation, excludeArgument, /*reportErrors*/ false)) {
19469-
candidateForArgumentError = checkCandidate;
19472+
// Give preference to error candidates that have no rest parameters (as they are more specific)
19473+
if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType(checkCandidate)) {
19474+
candidateForArgumentError = checkCandidate;
19475+
}
1947019476
continue;
1947119477
}
1947219478
}

0 commit comments

Comments
 (0)