mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Improve error message for overload that takes spread arguments
The original error message on the last line I have added to in
functionParameterArityMismatch.ts was
No overload expects 5 arguments, but overloads do exist that expect
either 4 or Infinity arguments.
even if we do not define a function that takes Infinity arguments.
This PR changes it to this:
Expected 0-6 arguments, but got 5 or more.
I feel it is still a bit strange but much more understandable.
Fixes #42418
This commit is contained in:
committed by
Eli Barzilay
parent
4fc9c8446d
commit
a3ead92046
@@ -27709,6 +27709,10 @@ namespace ts {
|
||||
max = Math.max(max, maxCount);
|
||||
}
|
||||
|
||||
if (min < argCount && argCount < max) {
|
||||
return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
|
||||
}
|
||||
|
||||
const hasRestParameter = some(signatures, hasEffectiveRestParameter);
|
||||
const paramRange = hasRestParameter ? min :
|
||||
min < max ? min + "-" + max :
|
||||
@@ -27742,9 +27746,6 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (min < argCount && argCount < max) {
|
||||
return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
|
||||
}
|
||||
|
||||
if (!hasSpreadArgument && argCount < min) {
|
||||
const diagnostic = getDiagnosticForCallNode(node, error, paramRange, argCount);
|
||||
|
||||
Reference in New Issue
Block a user