mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
85 lines
4.3 KiB
Plaintext
85 lines
4.3 KiB
Plaintext
destructuringParameterDeclaration3ES5.ts(12,13): error TS7019: Rest parameter 'a' implicitly has an 'any[]' type.
|
|
destructuringParameterDeclaration3ES5.ts(16,14): error TS7031: Binding element 'a' implicitly has an 'any' type.
|
|
destructuringParameterDeclaration3ES5.ts(16,17): error TS7031: Binding element 'b' implicitly has an 'any' type.
|
|
destructuringParameterDeclaration3ES5.ts(16,22): error TS7031: Binding element 'c' implicitly has an 'any' type.
|
|
destructuringParameterDeclaration3ES5.ts(17,15): error TS7031: Binding element 'a' implicitly has an 'any' type.
|
|
destructuringParameterDeclaration3ES5.ts(17,18): error TS7031: Binding element 'b' implicitly has an 'any' type.
|
|
destructuringParameterDeclaration3ES5.ts(17,23): error TS7031: Binding element 'c' implicitly has an 'any' type.
|
|
destructuringParameterDeclaration3ES5.ts(17,31): error TS7031: Binding element 'x' implicitly has an 'any' type.
|
|
destructuringParameterDeclaration3ES5.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
|
Source has 5 element(s) but target allows only 3.
|
|
destructuringParameterDeclaration3ES5.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
|
destructuringParameterDeclaration3ES5.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
|
Source has 2 element(s) but target requires 3.
|
|
|
|
|
|
==== destructuringParameterDeclaration3ES5.ts (11 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 a1(...x: (number|string)[]) { }
|
|
function a2(...a) { }
|
|
~~~~
|
|
!!! error TS7019: Rest parameter 'a' implicitly has an 'any[]' type.
|
|
function a3(...a: Array<String>) { }
|
|
function a4(...a: arrayString) { }
|
|
function a5(...a: stringOrNumArray) { }
|
|
function a9([a, b, [[c]]]) { }
|
|
~
|
|
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
|
|
~
|
|
!!! error TS7031: Binding element 'b' implicitly has an 'any' type.
|
|
~
|
|
!!! error TS7031: Binding element 'c' implicitly has an 'any' type.
|
|
function a10([a, b, [[c]], ...x]) { }
|
|
~
|
|
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
|
|
~
|
|
!!! error TS7031: Binding element 'b' implicitly has an 'any' type.
|
|
~
|
|
!!! error TS7031: Binding element 'c' implicitly has an 'any' type.
|
|
~
|
|
!!! error TS7031: Binding element 'x' implicitly has an 'any' type.
|
|
function a11([a, b, c, ...x]: number[]) { }
|
|
|
|
|
|
var array = [1, 2, 3];
|
|
var array2 = [true, false, "hello"];
|
|
a2([...array]);
|
|
a1(...array);
|
|
|
|
a9([1, 2, [["string"]], false, true]); // 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: Source has 5 element(s) but target allows only 3.
|
|
|
|
a10([1, 2, [["string"]], false, true]); // Parameter type is any[]
|
|
a10([1, 2, 3, false, true]); // Parameter type is any[]
|
|
~
|
|
!!! error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
|
a10([1, 2]); // Parameter type is any[]
|
|
~~~~~~
|
|
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
|
!!! error TS2345: Source has 2 element(s) but target requires 3.
|
|
a11([1, 2]); // Parameter type is number[]
|
|
|
|
// Rest parameter with generic
|
|
function foo<T>(...a: T[]) { }
|
|
foo<number|string>("hello", 1, 2);
|
|
foo("hello", "world");
|
|
|
|
enum E { a, b }
|
|
const enum E1 { a, b }
|
|
function foo1<T extends Number>(...a: T[]) { }
|
|
foo1(1, 2, 3, E.a);
|
|
foo1(1, 2, 3, E1.a, E.b);
|
|
|
|
|
|
|