Skip to content

Commit 6a08820

Browse files
committed
Improve spread arity mismatch error messages
Thanks @weswigham for the improved wording.
1 parent 865f328 commit 6a08820

7 files changed

+22
-22
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16505,9 +16505,9 @@ namespace ts {
1650516505
if (argCount <= max && hasSpreadArgument) {
1650616506
argCount--;
1650716507
}
16508-
const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_a_minimum_of_1 :
16508+
const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
1650916509
hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 :
16510-
hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_got_a_minimum_of_1 :
16510+
hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_got_1_or_more :
1651116511
Diagnostics.Expected_0_arguments_but_got_1;
1651216512
diagnostics.add(createDiagnosticForNode(node, error, paramCount, argCount));
1651316513
}

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,11 +1896,11 @@
18961896
"category": "Error",
18971897
"code": 2555
18981898
},
1899-
"Expected {0} arguments, but got a minimum of {1}.": {
1899+
"Expected {0} arguments, but got {1} or more.": {
19001900
"category": "Error",
19011901
"code": 2556
19021902
},
1903-
"Expected at least {0} arguments, but got a minimum of {1}.": {
1903+
"Expected at least {0} arguments, but got {1} or more.": {
19041904
"category": "Error",
19051905
"code": 2557
19061906
},

tests/baselines/reference/callWithSpread2.errors.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(22,1): error TS2556: Expected 1 arguments, but got a minimum of 2.
2-
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,1): error TS2556: Expected 0 arguments, but got a minimum of 1.
1+
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(22,1): error TS2556: Expected 1 arguments, but got 2 or more.
2+
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,1): error TS2556: Expected 0 arguments, but got 1 or more.
33
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(26,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
44
Type 'string' is not assignable to type 'number'.
55
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(27,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
@@ -12,9 +12,9 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,11): err
1212
Type 'string' is not assignable to type 'number'.
1313
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
1414
Type 'string' is not assignable to type 'number'.
15-
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0.
16-
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0.
17-
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0.
15+
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,1): error TS2556: Expected 1-3 arguments, but got 0 or more.
16+
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,1): error TS2556: Expected 1-3 arguments, but got 0 or more.
17+
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): error TS2556: Expected 1-3 arguments, but got 0 or more.
1818

1919

2020
==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (11 errors) ====
@@ -41,10 +41,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): erro
4141
// extra arguments
4242
normal("g", ...ns)
4343
~~~~~~~~~~~~~~~~~~
44-
!!! error TS2556: Expected 1 arguments, but got a minimum of 2.
44+
!!! error TS2556: Expected 1 arguments, but got 2 or more.
4545
thunk(...ns)
4646
~~~~~~~~~~~~
47-
!!! error TS2556: Expected 0 arguments, but got a minimum of 1.
47+
!!! error TS2556: Expected 0 arguments, but got 1 or more.
4848

4949
// bad
5050
all(...mixed)
@@ -73,11 +73,11 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): erro
7373
!!! error TS2345: Type 'string' is not assignable to type 'number'.
7474
prefix(...ns) // required parameters are required
7575
~~~~~~~~~~~~~
76-
!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0.
76+
!!! error TS2556: Expected 1-3 arguments, but got 0 or more.
7777
prefix(...mixed)
7878
~~~~~~~~~~~~~~~~
79-
!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0.
79+
!!! error TS2556: Expected 1-3 arguments, but got 0 or more.
8080
prefix(...tuple)
8181
~~~~~~~~~~~~~~~~
82-
!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0.
82+
!!! error TS2556: Expected 1-3 arguments, but got 0 or more.
8383

tests/baselines/reference/iteratorSpreadInCall.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0.
1+
tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more.
22

33

44
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556:
1818

1919
foo(...new SymbolIterator);
2020
~~~~~~~~~~~~~~~~~~~~~~~~~~
21-
!!! error TS2556: Expected 1 arguments, but got a minimum of 0.
21+
!!! error TS2556: Expected 1 arguments, but got 0 or more.

tests/baselines/reference/iteratorSpreadInCall10.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0.
1+
tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more.
22

33

44
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556
1818

1919
foo(...new SymbolIterator);
2020
~~~~~~~~~~~~~~~~~~~~~~~~~~
21-
!!! error TS2556: Expected 1 arguments, but got a minimum of 0.
21+
!!! error TS2556: Expected 1 arguments, but got 0 or more.

tests/baselines/reference/iteratorSpreadInCall2.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0.
1+
tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more.
22

33

44
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556:
1818

1919
foo(...new SymbolIterator);
2020
~~~~~~~~~~~~~~~~~~~~~~~~~~
21-
!!! error TS2556: Expected 1 arguments, but got a minimum of 0.
21+
!!! error TS2556: Expected 1 arguments, but got 0 or more.

tests/baselines/reference/iteratorSpreadInCall4.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557: Expected at least 1 arguments, but got a minimum of 0.
1+
tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557: Expected at least 1 arguments, but got 0 or more.
22

33

44
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557:
1818

1919
foo(...new SymbolIterator);
2020
~~~~~~~~~~~~~~~~~~~~~~~~~~
21-
!!! error TS2557: Expected at least 1 arguments, but got a minimum of 0.
21+
!!! error TS2557: Expected at least 1 arguments, but got 0 or more.

0 commit comments

Comments
 (0)