Improve spread arity mismatch error messages

Thanks @weswigham for the improved wording.
This commit is contained in:
Nathan Shively-Sanders
2017-11-16 10:28:17 -08:00
parent 865f3281bc
commit 6a08820fe7
7 changed files with 22 additions and 22 deletions

View File

@@ -16505,9 +16505,9 @@ namespace ts {
if (argCount <= max && hasSpreadArgument) {
argCount--;
}
const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_a_minimum_of_1 :
const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 :
hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_got_a_minimum_of_1 :
hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_got_1_or_more :
Diagnostics.Expected_0_arguments_but_got_1;
diagnostics.add(createDiagnosticForNode(node, error, paramCount, argCount));
}

View File

@@ -1896,11 +1896,11 @@
"category": "Error",
"code": 2555
},
"Expected {0} arguments, but got a minimum of {1}.": {
"Expected {0} arguments, but got {1} or more.": {
"category": "Error",
"code": 2556
},
"Expected at least {0} arguments, but got a minimum of {1}.": {
"Expected at least {0} arguments, but got {1} or more.": {
"category": "Error",
"code": 2557
},

View File

@@ -1,5 +1,5 @@
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(22,1): error TS2556: Expected 1 arguments, but got a minimum of 2.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,1): error TS2556: Expected 0 arguments, but got a minimum of 1.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(22,1): error TS2556: Expected 1 arguments, but got 2 or more.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,1): error TS2556: Expected 0 arguments, but got 1 or more.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(26,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
Type 'string' is not assignable to type 'number'.
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
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,1): error TS2556: Expected 1-3 arguments, but got 0 or more.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,1): error TS2556: Expected 1-3 arguments, but got 0 or more.
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): error TS2556: Expected 1-3 arguments, but got 0 or more.
==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (11 errors) ====
@@ -41,10 +41,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): erro
// extra arguments
normal("g", ...ns)
~~~~~~~~~~~~~~~~~~
!!! error TS2556: Expected 1 arguments, but got a minimum of 2.
!!! error TS2556: Expected 1 arguments, but got 2 or more.
thunk(...ns)
~~~~~~~~~~~~
!!! error TS2556: Expected 0 arguments, but got a minimum of 1.
!!! error TS2556: Expected 0 arguments, but got 1 or more.
// bad
all(...mixed)
@@ -73,11 +73,11 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): erro
!!! error TS2345: Type 'string' is not assignable to type 'number'.
prefix(...ns) // required parameters are required
~~~~~~~~~~~~~
!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0.
!!! error TS2556: Expected 1-3 arguments, but got 0 or more.
prefix(...mixed)
~~~~~~~~~~~~~~~~
!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0.
!!! error TS2556: Expected 1-3 arguments, but got 0 or more.
prefix(...tuple)
~~~~~~~~~~~~~~~~
!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0.
!!! error TS2556: Expected 1-3 arguments, but got 0 or more.

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0.
tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556:
foo(...new SymbolIterator);
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2556: Expected 1 arguments, but got a minimum of 0.
!!! error TS2556: Expected 1 arguments, but got 0 or more.

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0.
tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556
foo(...new SymbolIterator);
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2556: Expected 1 arguments, but got a minimum of 0.
!!! error TS2556: Expected 1 arguments, but got 0 or more.

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0.
tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556:
foo(...new SymbolIterator);
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2556: Expected 1 arguments, but got a minimum of 0.
!!! error TS2556: Expected 1 arguments, but got 0 or more.

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557: Expected at least 1 arguments, but got a minimum of 0.
tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557: Expected at least 1 arguments, but got 0 or more.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ====
@@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557:
foo(...new SymbolIterator);
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2557: Expected at least 1 arguments, but got a minimum of 0.
!!! error TS2557: Expected at least 1 arguments, but got 0 or more.