145 lines
7.4 KiB
Text
145 lines
7.4 KiB
Text
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts ===
|
|
|
|
// 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>
|
|
>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0))
|
|
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
|
|
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
|
|
|
|
type someArray = Array<String> | number[];
|
|
>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32))
|
|
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
|
|
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
|
|
|
|
type stringOrNumArray = Array<String|Number>;
|
|
>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42))
|
|
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
|
|
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
|
|
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
|
|
|
|
function a1(...x: (number|string)[]) { }
|
|
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES6.ts, 9, 45))
|
|
>x : Symbol(x, Decl(destructuringParameterDeclaration3ES6.ts, 11, 12))
|
|
|
|
function a2(...a) { }
|
|
>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES6.ts, 11, 40))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 12, 12))
|
|
|
|
function a3(...a: Array<String>) { }
|
|
>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12))
|
|
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
|
|
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
|
|
|
|
function a4(...a: arrayString) { }
|
|
>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 14, 12))
|
|
>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0))
|
|
|
|
function a5(...a: stringOrNumArray) { }
|
|
>a5 : Symbol(a5, Decl(destructuringParameterDeclaration3ES6.ts, 14, 34))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 15, 12))
|
|
>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42))
|
|
|
|
function a9([a, b, [[c]]]) { }
|
|
>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES6.ts, 15, 39))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 16, 13))
|
|
>b : Symbol(b, Decl(destructuringParameterDeclaration3ES6.ts, 16, 15))
|
|
>c : Symbol(c, Decl(destructuringParameterDeclaration3ES6.ts, 16, 21))
|
|
|
|
function a10([a, b, [[c]], ...x]) { }
|
|
>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 17, 14))
|
|
>b : Symbol(b, Decl(destructuringParameterDeclaration3ES6.ts, 17, 16))
|
|
>c : Symbol(c, Decl(destructuringParameterDeclaration3ES6.ts, 17, 22))
|
|
>x : Symbol(x, Decl(destructuringParameterDeclaration3ES6.ts, 17, 26))
|
|
|
|
function a11([a, b, c, ...x]: number[]) { }
|
|
>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES6.ts, 17, 37))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 18, 14))
|
|
>b : Symbol(b, Decl(destructuringParameterDeclaration3ES6.ts, 18, 16))
|
|
>c : Symbol(c, Decl(destructuringParameterDeclaration3ES6.ts, 18, 19))
|
|
>x : Symbol(x, Decl(destructuringParameterDeclaration3ES6.ts, 18, 22))
|
|
|
|
|
|
var array = [1, 2, 3];
|
|
>array : Symbol(array, Decl(destructuringParameterDeclaration3ES6.ts, 21, 3))
|
|
|
|
var array2 = [true, false, "hello"];
|
|
>array2 : Symbol(array2, Decl(destructuringParameterDeclaration3ES6.ts, 22, 3))
|
|
|
|
a2([...array]);
|
|
>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES6.ts, 11, 40))
|
|
>array : Symbol(array, Decl(destructuringParameterDeclaration3ES6.ts, 21, 3))
|
|
|
|
a1(...array);
|
|
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES6.ts, 9, 45))
|
|
>array : Symbol(array, Decl(destructuringParameterDeclaration3ES6.ts, 21, 3))
|
|
|
|
a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]]
|
|
>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES6.ts, 15, 39))
|
|
|
|
a10([1, 2, [["string"]], false, true]); // Parameter type is any[]
|
|
>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30))
|
|
|
|
a10([1, 2, 3, false, true]); // Parameter type is any[]
|
|
>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30))
|
|
|
|
a10([1, 2]); // Parameter type is any[]
|
|
>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES6.ts, 16, 30))
|
|
|
|
a11([1, 2]); // Parameter type is number[]
|
|
>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES6.ts, 17, 37))
|
|
|
|
// Rest parameter with generic
|
|
function foo<T>(...a: T[]) { }
|
|
>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES6.ts, 31, 12))
|
|
>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 34, 13))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 34, 16))
|
|
>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 34, 13))
|
|
|
|
foo<number|string>("hello", 1, 2);
|
|
>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES6.ts, 31, 12))
|
|
|
|
foo("hello", "world");
|
|
>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES6.ts, 31, 12))
|
|
|
|
enum E { a, b }
|
|
>E : Symbol(E, Decl(destructuringParameterDeclaration3ES6.ts, 36, 22))
|
|
>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES6.ts, 38, 8))
|
|
>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES6.ts, 38, 11))
|
|
|
|
const enum E1 { a, b }
|
|
>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES6.ts, 38, 15))
|
|
>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES6.ts, 39, 15))
|
|
>b : Symbol(E1.b, Decl(destructuringParameterDeclaration3ES6.ts, 39, 18))
|
|
|
|
function foo1<T extends Number>(...a: T[]) { }
|
|
>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES6.ts, 39, 22))
|
|
>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 40, 14))
|
|
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
|
|
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 40, 32))
|
|
>T : Symbol(T, Decl(destructuringParameterDeclaration3ES6.ts, 40, 14))
|
|
|
|
foo1(1, 2, 3, E.a);
|
|
>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES6.ts, 39, 22))
|
|
>E.a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES6.ts, 38, 8))
|
|
>E : Symbol(E, Decl(destructuringParameterDeclaration3ES6.ts, 36, 22))
|
|
>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES6.ts, 38, 8))
|
|
|
|
foo1(1, 2, 3, E1.a, E.b);
|
|
>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES6.ts, 39, 22))
|
|
>E1.a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES6.ts, 39, 15))
|
|
>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES6.ts, 38, 15))
|
|
>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES6.ts, 39, 15))
|
|
>E.b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES6.ts, 38, 11))
|
|
>E : Symbol(E, Decl(destructuringParameterDeclaration3ES6.ts, 36, 22))
|
|
>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES6.ts, 38, 11))
|
|
|
|
|
|
|