@@ -21439,7 +21439,7 @@ namespace ts {
21439
21439
// function foo(): void;
21440
21440
// foo<number>(0);
21441
21441
//
21442
- let candidateForArgumentError : Signature | undefined;
21442
+ let candidatesForArgumentError : Signature[] | undefined;
21443
21443
let candidateForArgumentArityError: Signature | undefined;
21444
21444
let candidateForTypeArgumentError: Signature | undefined;
21445
21445
let result: Signature | undefined;
@@ -21474,8 +21474,13 @@ namespace ts {
21474
21474
// If candidate is undefined, it means that no candidates had a suitable arity. In that case,
21475
21475
// skip the checkApplicableSignature check.
21476
21476
if (reportErrors) {
21477
- if (candidateForArgumentError) {
21478
- checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, CheckMode.Normal, /*reportErrors*/ true);
21477
+ if (candidatesForArgumentError) {
21478
+ createDiagnosticForNodeFromMessageChain // is what I really want to call
21479
+ chainDiagnosticMessages(chain, Diagnostics.Failed_to_find_a_suitable_overload_for_this_call);
21480
+ diagnostics.add(createDiagnosticForNode(node, Diagnostics.Failed_to_find_a_suitable_overload_for_this_call));
21481
+ for (const c of candidatesForArgumentError) {
21482
+ checkApplicableSignature(node, args, c, assignableRelation, CheckMode.Normal, /*reportErrors*/ true);
21483
+ }
21479
21484
}
21480
21485
else if (candidateForArgumentArityError) {
21481
21486
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
@@ -21500,7 +21505,7 @@ namespace ts {
21500
21505
return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
21501
21506
21502
21507
function chooseOverload(candidates: Signature[], relation: Map<RelationComparisonResult>, signatureHelpTrailingComma = false) {
21503
- candidateForArgumentError = undefined;
21508
+ candidatesForArgumentError = undefined;
21504
21509
candidateForArgumentArityError = undefined;
21505
21510
candidateForTypeArgumentError = undefined;
21506
21511
@@ -21510,7 +21515,7 @@ namespace ts {
21510
21515
return undefined;
21511
21516
}
21512
21517
if (!checkApplicableSignature(node, args, candidate, relation, CheckMode.Normal, /*reportErrors*/ false)) {
21513
- candidateForArgumentError = candidate;
21518
+ candidatesForArgumentError = [ candidate] ;
21514
21519
return undefined;
21515
21520
}
21516
21521
return candidate;
@@ -21552,8 +21557,8 @@ namespace ts {
21552
21557
}
21553
21558
if (!checkApplicableSignature(node, args, checkCandidate, relation, argCheckMode, /*reportErrors*/ false)) {
21554
21559
// Give preference to error candidates that have no rest parameters (as they are more specific)
21555
- if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType (checkCandidate)) {
21556
- candidateForArgumentError = checkCandidate;
21560
+ if (getMinArgumentCount(checkCandidate) <= args.length && args.length <= getParameterCount (checkCandidate)) {
21561
+ (candidatesForArgumentError || (candidatesForArgumentError = [])).push( checkCandidate) ;
21557
21562
}
21558
21563
continue;
21559
21564
}
@@ -21574,8 +21579,8 @@ namespace ts {
21574
21579
}
21575
21580
if (!checkApplicableSignature(node, args, checkCandidate, relation, argCheckMode, /*reportErrors*/ false)) {
21576
21581
// Give preference to error candidates that have no rest parameters (as they are more specific)
21577
- if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType (checkCandidate)) {
21578
- candidateForArgumentError = checkCandidate;
21582
+ if (getMinArgumentCount(checkCandidate) <= args.length && args.length <= getParameterCount (checkCandidate)) {
21583
+ (candidatesForArgumentError || (candidatesForArgumentError = [])).push( checkCandidate) ;
21579
21584
}
21580
21585
continue;
21581
21586
}
0 commit comments