84 lines
No EOL
5.1 KiB
Text
84 lines
No EOL
5.1 KiB
Text
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
|
|
Type 'boolean' is not assignable to type 'number'.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
|
Types of property '2' are incompatible.
|
|
Type 'string' is not assignable to type '[[any]]'.
|
|
Property '0' is missing in type 'String'.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
|
Property '2' is missing in type '[number, number]'.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
|
Type 'string | number' is not assignable to type 'number'.
|
|
Type 'string' is not assignable to type 'number'.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(29,24): error TS1005: ',' expected.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,22): error TS2304: Cannot find name 'E1'.
|
|
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,28): error TS2304: Cannot find name 'E'.
|
|
|
|
|
|
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts (10 errors) ====
|
|
// If the parameter is a rest parameter, the parameter type is any[]
|
|
// A type annotation for a rest parameter must denote an array type.
|
|
|
|
// RestParameter:
|
|
// ... Identifier TypeAnnotation(opt)
|
|
|
|
type arrayString = Array<String>
|
|
type someArray = Array<String> | number[];
|
|
type stringOrNumArray = Array<String|Number>;
|
|
|
|
function a0(...x: [number, number, string]) { } // Error, rest parameter must be array type
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2370: A rest parameter must be of an array type.
|
|
function a1(...x: (number|string)[]) { }
|
|
function a2(...a: someArray) { } // Error, rest parameter must be array type
|
|
~~~~~~~~~~~~~~~
|
|
!!! error TS2370: A rest parameter must be of an array type.
|
|
function a3(...b?) { } // Error, can't be optional
|
|
function a4(...b = [1,2,3]) { } // Error, can't have initializer
|
|
function a5([a, b, [[c]]]) { }
|
|
function a6([a, b, c, ...x]: number[]) { }
|
|
|
|
|
|
a1(1, 2, "hello", true); // Error, parameter type is (number|string)[]
|
|
~~~~
|
|
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
|
|
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
|
|
a1(...array2); // Error parameter type is (number|string)[]
|
|
~~~~~~
|
|
!!! error TS2304: Cannot find name 'array2'.
|
|
a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
|
!!! error TS2345: Types of property '2' are incompatible.
|
|
!!! error TS2345: Type 'string' is not assignable to type '[[any]]'.
|
|
!!! error TS2345: Property '0' is missing in type 'String'.
|
|
a5([1, 2]); // Error, parameter type is [any, any, [[any]]]
|
|
~~~~~~
|
|
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
|
!!! error TS2345: Property '2' is missing in type '[number, number]'.
|
|
a6([1, 2, "string"]); // Error, parameter type is number[]
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
|
!!! error TS2345: Type 'string | number' is not assignable to type 'number'.
|
|
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
|
|
|
|
|
var temp = [1, 2, 3];
|
|
class C {
|
|
constructor(public ...temp) { } // Error, rest parameter can't have accessibilityModifier
|
|
~~~
|
|
!!! error TS1005: ',' expected.
|
|
}
|
|
|
|
// Rest parameter with generic
|
|
function foo1<T extends Number>(...a: T[]) { }
|
|
foo1(1, 2, "string", E1.a, E.b); // Error
|
|
~~
|
|
!!! error TS2304: Cannot find name 'E1'.
|
|
~
|
|
!!! error TS2304: Cannot find name 'E'.
|
|
|
|
|
|
|