120 lines
7.3 KiB
Text
120 lines
7.3 KiB
Text
=== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5.ts ===
|
|
// The type T associated with a destructuring variable declaration is determined as follows:
|
|
// If the declaration includes a type annotation, T is that type.
|
|
var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" }
|
|
>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5.ts, 2, 5))
|
|
>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5.ts, 2, 8))
|
|
>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5.ts, 2, 15))
|
|
>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5.ts, 2, 27))
|
|
>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5.ts, 2, 44))
|
|
>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5.ts, 2, 52))
|
|
|
|
var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true];
|
|
>a3 : Symbol(a3, Decl(destructuringVariableDeclaration1ES5.ts, 3, 5))
|
|
>a4 : Symbol(a4, Decl(destructuringVariableDeclaration1ES5.ts, 3, 11))
|
|
>a5 : Symbol(a5, Decl(destructuringVariableDeclaration1ES5.ts, 3, 16))
|
|
|
|
// The type T associated with a destructuring variable declaration is determined as follows:
|
|
// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression.
|
|
var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } };
|
|
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 7, 44))
|
|
>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 11))
|
|
>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 21))
|
|
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 7, 44))
|
|
>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 50))
|
|
|
|
var temp = { t1: true, t2: "false" };
|
|
>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5.ts, 8, 3))
|
|
>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES5.ts, 8, 12))
|
|
>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES5.ts, 8, 22))
|
|
|
|
var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }];
|
|
>b2 : Symbol(b2, Decl(destructuringVariableDeclaration1ES5.ts, 9, 5))
|
|
>b3 : Symbol(b3, Decl(destructuringVariableDeclaration1ES5.ts, 9, 12))
|
|
>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 9, 23))
|
|
>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5.ts, 8, 3))
|
|
>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES5.ts, 9, 49))
|
|
>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES5.ts, 9, 60))
|
|
|
|
var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined];
|
|
>b5 : Symbol(b5, Decl(destructuringVariableDeclaration1ES5.ts, 10, 5))
|
|
>b6 : Symbol(b6, Decl(destructuringVariableDeclaration1ES5.ts, 10, 12))
|
|
>b7 : Symbol(b7, Decl(destructuringVariableDeclaration1ES5.ts, 10, 23))
|
|
>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5.ts, 8, 3))
|
|
>undefined : Symbol(undefined)
|
|
>undefined : Symbol(undefined)
|
|
>undefined : Symbol(undefined)
|
|
|
|
// The type T associated with a binding element is determined as follows:
|
|
// If the binding element is a rest element, T is an array type with
|
|
// an element type E, where E is the type of the numeric index signature of S.
|
|
var [...c1] = [1,2,3];
|
|
>c1 : Symbol(c1, Decl(destructuringVariableDeclaration1ES5.ts, 15, 5))
|
|
|
|
var [...c2] = [1,2,3, "string"];
|
|
>c2 : Symbol(c2, Decl(destructuringVariableDeclaration1ES5.ts, 16, 5))
|
|
|
|
// The type T associated with a binding element is determined as follows:
|
|
// Otherwise, if S is a tuple- like type (section 3.3.3):
|
|
// Let N be the zero-based index of the binding element in the array binding pattern.
|
|
// If S has a property with the numerical name N, T is the type of that property.
|
|
var [d1,d2] = [1,"string"]
|
|
>d1 : Symbol(d1, Decl(destructuringVariableDeclaration1ES5.ts, 22, 5))
|
|
>d2 : Symbol(d2, Decl(destructuringVariableDeclaration1ES5.ts, 22, 8))
|
|
|
|
// The type T associated with a binding element is determined as follows:
|
|
// Otherwise, if S is a tuple- like type (section 3.3.3):
|
|
// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature.
|
|
var temp1 = [true, false, true]
|
|
>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES5.ts, 27, 3))
|
|
|
|
var [d3, d4] = [1, "string", ...temp1];
|
|
>d3 : Symbol(d3, Decl(destructuringVariableDeclaration1ES5.ts, 28, 5))
|
|
>d4 : Symbol(d4, Decl(destructuringVariableDeclaration1ES5.ts, 28, 8))
|
|
>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES5.ts, 27, 3))
|
|
|
|
// Combining both forms of destructuring,
|
|
var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] };
|
|
>e : Symbol(e, Decl(destructuringVariableDeclaration1ES5.ts, 31, 49))
|
|
>e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 9))
|
|
>e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES5.ts, 31, 12))
|
|
>e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES5.ts, 31, 16))
|
|
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 23))
|
|
>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 31, 33))
|
|
>e : Symbol(e, Decl(destructuringVariableDeclaration1ES5.ts, 31, 49))
|
|
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 61))
|
|
>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 31, 68))
|
|
|
|
var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] };
|
|
>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5.ts, 32, 41))
|
|
>f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES5.ts, 32, 9))
|
|
>f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES5.ts, 32, 12))
|
|
>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES5.ts, 32, 53))
|
|
>f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES5.ts, 32, 18))
|
|
>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5.ts, 32, 26))
|
|
>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5.ts, 32, 41))
|
|
>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES5.ts, 32, 53))
|
|
>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5.ts, 32, 60))
|
|
|
|
// When a destructuring variable declaration, binding property, or binding element specifies
|
|
// an initializer expression, the type of the initializer expression is required to be assignable
|
|
// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element.
|
|
var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } };
|
|
>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 36))
|
|
>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 9))
|
|
>undefined : Symbol(undefined)
|
|
>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 36))
|
|
>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 41))
|
|
>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 59))
|
|
>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 64))
|
|
|
|
var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } };
|
|
>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 36))
|
|
>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 9))
|
|
>undefined : Symbol(undefined)
|
|
>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 36))
|
|
>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 41))
|
|
>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 62))
|
|
>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 67))
|
|
|
|
|