//// [tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts] ////

=== destructuringParameterDeclaration1ES5.ts ===
// A parameter declaration may specify either an identifier or a binding pattern.
// The identifiers specified in parameter declarations and binding patterns
// in a parameter list must be unique within that parameter list.

// If the declaration includes a type annotation, the parameter is of that type
function a1([a, b, [[c]]]: [number, number, string[][]]) { }
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration1ES5.ts, 0, 0))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 5, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 5, 15))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 5, 21))

function a2(o: { x: number, a: number }) { }
>a2 : Symbol(a2, Decl(destructuringParameterDeclaration1ES5.ts, 5, 60))
>o : Symbol(o, Decl(destructuringParameterDeclaration1ES5.ts, 6, 12))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 6, 16))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 6, 27))

function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { };
>a3 : Symbol(a3, Decl(destructuringParameterDeclaration1ES5.ts, 6, 44))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES5.ts, 7, 13))
>k : Symbol(k, Decl(destructuringParameterDeclaration1ES5.ts, 7, 15))
>l : Symbol(l, Decl(destructuringParameterDeclaration1ES5.ts, 7, 68))
>m : Symbol(m, Decl(destructuringParameterDeclaration1ES5.ts, 7, 23))
>n : Symbol(n, Decl(destructuringParameterDeclaration1ES5.ts, 7, 25))
>q : Symbol(q, Decl(destructuringParameterDeclaration1ES5.ts, 7, 98))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 7, 34))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 7, 36))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 7, 39))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES5.ts, 7, 46))
>k : Symbol(k, Decl(destructuringParameterDeclaration1ES5.ts, 7, 57))
>l : Symbol(l, Decl(destructuringParameterDeclaration1ES5.ts, 7, 68))
>m : Symbol(m, Decl(destructuringParameterDeclaration1ES5.ts, 7, 73))
>n : Symbol(n, Decl(destructuringParameterDeclaration1ES5.ts, 7, 85))
>q : Symbol(q, Decl(destructuringParameterDeclaration1ES5.ts, 7, 98))

function a4({x, a}: { x: number, a: number }) { }
>a4 : Symbol(a4, Decl(destructuringParameterDeclaration1ES5.ts, 7, 127))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 8, 13))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 8, 15))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 8, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 8, 32))

a1([1, 2, [["world"]]]);
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration1ES5.ts, 0, 0))

a1([1, 2, [["world"]], 3]);
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration1ES5.ts, 0, 0))

// If the declaration includes an initializer expression (which is permitted only
// when the parameter list occurs in conjunction with a function body),
// the parameter type is the widened form (section 3.11) of the type of the initializer expression.

function b1(z = [undefined, null]) { };
>b1 : Symbol(b1, Decl(destructuringParameterDeclaration1ES5.ts, 11, 27))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 17, 12))
>undefined : Symbol(undefined)

function b2(z = null, o = { x: 0, y: undefined }) { }
>b2 : Symbol(b2, Decl(destructuringParameterDeclaration1ES5.ts, 17, 39))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 18, 12))
>o : Symbol(o, Decl(destructuringParameterDeclaration1ES5.ts, 18, 21))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 18, 27))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 18, 33))
>undefined : Symbol(undefined)

function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
>b3 : Symbol(b3, Decl(destructuringParameterDeclaration1ES5.ts, 18, 53))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 19, 32))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 19, 17))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 19, 46))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES5.ts, 19, 24))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 19, 32))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 19, 37))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 19, 46))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES5.ts, 19, 51))

interface F1 {
>F1 : Symbol(F1, Decl(destructuringParameterDeclaration1ES5.ts, 19, 67))

    b5(z, y, [, a, b], {p, m: { q, r}});
>b5 : Symbol(F1.b5, Decl(destructuringParameterDeclaration1ES5.ts, 21, 14))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 22, 7))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 22, 9))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 22, 15))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 22, 18))
>p : Symbol(p, Decl(destructuringParameterDeclaration1ES5.ts, 22, 24))
>m : Symbol(m)
>q : Symbol(q, Decl(destructuringParameterDeclaration1ES5.ts, 22, 31))
>r : Symbol(r, Decl(destructuringParameterDeclaration1ES5.ts, 22, 34))
}

function b6([a, z, y] = [undefined, null, undefined]) { }
>b6 : Symbol(b6, Decl(destructuringParameterDeclaration1ES5.ts, 23, 1))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 25, 13))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 25, 15))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 25, 18))
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)

function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { }
>b7 : Symbol(b7, Decl(destructuringParameterDeclaration1ES5.ts, 25, 57))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 26, 14))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 26, 17))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 26, 23))
>d : Symbol(d, Decl(destructuringParameterDeclaration1ES5.ts, 26, 25))
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)

b1([1, 2, 3]);  // z is widen to the type any[]
>b1 : Symbol(b1, Decl(destructuringParameterDeclaration1ES5.ts, 11, 27))

b2("string", { x: 200, y: "string" });
>b2 : Symbol(b2, Decl(destructuringParameterDeclaration1ES5.ts, 17, 39))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 29, 14))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 29, 22))

b2("string", { x: 200, y: true });
>b2 : Symbol(b2, Decl(destructuringParameterDeclaration1ES5.ts, 17, 39))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 30, 14))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 30, 22))

b6(["string", 1, 2]);                    // Shouldn't be an error
>b6 : Symbol(b6, Decl(destructuringParameterDeclaration1ES5.ts, 23, 1))

b7([["string"], 1, [[true, false]]]);    // Shouldn't be an error
>b7 : Symbol(b7, Decl(destructuringParameterDeclaration1ES5.ts, 25, 57))


// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3)
enum Foo { a }
>Foo : Symbol(Foo, Decl(destructuringParameterDeclaration1ES5.ts, 32, 37))
>a : Symbol(Foo.a, Decl(destructuringParameterDeclaration1ES5.ts, 36, 10))

function c0({z: {x, y: {j}}}) { }
>c0 : Symbol(c0, Decl(destructuringParameterDeclaration1ES5.ts, 36, 14))
>z : Symbol(z)
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 37, 17))
>y : Symbol(y)
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES5.ts, 37, 24))

function c1({z} = { z: 10 }) { }
>c1 : Symbol(c1, Decl(destructuringParameterDeclaration1ES5.ts, 37, 33))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 38, 13))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 38, 19))

function c2({z = 10}) { }
>c2 : Symbol(c2, Decl(destructuringParameterDeclaration1ES5.ts, 38, 32))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 39, 13))

function c3({b}: { b: number|string} = { b: "hello" }) { }
>c3 : Symbol(c3, Decl(destructuringParameterDeclaration1ES5.ts, 39, 25))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 40, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 40, 18))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 40, 40))

function c5([a, b, [[c]]]) { }
>c5 : Symbol(c5, Decl(destructuringParameterDeclaration1ES5.ts, 40, 58))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 41, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 41, 15))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 41, 21))

function c6([a, b, [[c=1]]]) { }
>c6 : Symbol(c6, Decl(destructuringParameterDeclaration1ES5.ts, 41, 30))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 42, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 42, 15))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 42, 21))

c0({z : { x: 1, y: { j: "world" } }});      // Implied type is { z: {x: any, y: {j: any}} }
>c0 : Symbol(c0, Decl(destructuringParameterDeclaration1ES5.ts, 36, 14))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 44, 4))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 44, 9))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 44, 15))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES5.ts, 44, 20))

c0({z : { x: "string", y: { j: true } }});  // Implied type is { z: {x: any, y: {j: any}} }
>c0 : Symbol(c0, Decl(destructuringParameterDeclaration1ES5.ts, 36, 14))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 45, 4))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 45, 9))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 45, 22))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES5.ts, 45, 27))

c1();             // Implied type is {z:number}?
>c1 : Symbol(c1, Decl(destructuringParameterDeclaration1ES5.ts, 37, 33))

c1({ z: 1 })      // Implied type is {z:number}? 
>c1 : Symbol(c1, Decl(destructuringParameterDeclaration1ES5.ts, 37, 33))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 48, 4))

c2({});         // Implied type is {z?: number}
>c2 : Symbol(c2, Decl(destructuringParameterDeclaration1ES5.ts, 38, 32))

c2({z:1});      // Implied type is {z?: number}
>c2 : Symbol(c2, Decl(destructuringParameterDeclaration1ES5.ts, 38, 32))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 51, 4))

c3({ b: 1 });     // Implied type is { b: number|string }.
>c3 : Symbol(c3, Decl(destructuringParameterDeclaration1ES5.ts, 39, 25))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 53, 4))

c5([1, 2, [["string"]]]);               // Implied type is is [any, any, [[any]]]
>c5 : Symbol(c5, Decl(destructuringParameterDeclaration1ES5.ts, 40, 58))

c5([1, 2, [["string"]], false, true]);  // Implied type is is [any, any, [[any]]]
>c5 : Symbol(c5, Decl(destructuringParameterDeclaration1ES5.ts, 40, 58))

// A parameter can be marked optional by following its name or binding pattern with a question mark (?)
// or by including an initializer.

function d0(x?) { }
>d0 : Symbol(d0, Decl(destructuringParameterDeclaration1ES5.ts, 56, 38), Decl(destructuringParameterDeclaration1ES5.ts, 61, 19))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 61, 12))

function d0(x = 10) { }
>d0 : Symbol(d0, Decl(destructuringParameterDeclaration1ES5.ts, 56, 38), Decl(destructuringParameterDeclaration1ES5.ts, 61, 19))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 62, 12))

interface F2 {
>F2 : Symbol(F2, Decl(destructuringParameterDeclaration1ES5.ts, 62, 23))

    d3([a, b, c]?);
>d3 : Symbol(F2.d3, Decl(destructuringParameterDeclaration1ES5.ts, 64, 14))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 65, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 65, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 65, 13))

    d4({x, y, z}?);
>d4 : Symbol(F2.d4, Decl(destructuringParameterDeclaration1ES5.ts, 65, 19))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 66, 8))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 66, 10))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 66, 13))

    e0([a, b, c]);
>e0 : Symbol(F2.e0, Decl(destructuringParameterDeclaration1ES5.ts, 66, 19))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 67, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 67, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 67, 13))
}

class C2 implements F2 {
>C2 : Symbol(C2, Decl(destructuringParameterDeclaration1ES5.ts, 68, 1))
>F2 : Symbol(F2, Decl(destructuringParameterDeclaration1ES5.ts, 62, 23))

    constructor() { }
    d3() { }
>d3 : Symbol(C2.d3, Decl(destructuringParameterDeclaration1ES5.ts, 71, 21))

    d4() { }
>d4 : Symbol(C2.d4, Decl(destructuringParameterDeclaration1ES5.ts, 72, 12))

    e0([a, b, c]) { }
>e0 : Symbol(C2.e0, Decl(destructuringParameterDeclaration1ES5.ts, 73, 12))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 74, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 74, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 74, 13))
}

class C3 implements F2 {
>C3 : Symbol(C3, Decl(destructuringParameterDeclaration1ES5.ts, 75, 1))
>F2 : Symbol(F2, Decl(destructuringParameterDeclaration1ES5.ts, 62, 23))

    d3([a, b, c]) { }
>d3 : Symbol(C3.d3, Decl(destructuringParameterDeclaration1ES5.ts, 77, 24))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 78, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 78, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 78, 13))

    d4({x, y, z}) { }
>d4 : Symbol(C3.d4, Decl(destructuringParameterDeclaration1ES5.ts, 78, 21))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 79, 8))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 79, 10))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES5.ts, 79, 13))

    e0([a, b, c]) { }
>e0 : Symbol(C3.e0, Decl(destructuringParameterDeclaration1ES5.ts, 79, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 80, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 80, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 80, 13))
}


function d5({x, y} = { x: 1, y: 2 }) { }
>d5 : Symbol(d5, Decl(destructuringParameterDeclaration1ES5.ts, 81, 1))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 84, 13))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 84, 15))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 84, 22))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES5.ts, 84, 28))

d5();  // Parameter is optional as its declaration included an initializer
>d5 : Symbol(d5, Decl(destructuringParameterDeclaration1ES5.ts, 81, 1))

// Destructuring parameter declarations do not permit type annotations on the individual binding patterns,
// as such annotations would conflict with the already established meaning of colons in object literals.
// Type annotations must instead be written on the top- level parameter declaration

function e1({x: number}) { }  // x has type any NOT number
>e1 : Symbol(e1, Decl(destructuringParameterDeclaration1ES5.ts, 85, 5))
>x : Symbol(x)
>number : Symbol(number, Decl(destructuringParameterDeclaration1ES5.ts, 91, 13))

function e2({x}: { x: number }) { }  // x is type number
>e2 : Symbol(e2, Decl(destructuringParameterDeclaration1ES5.ts, 91, 28))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 92, 13))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 92, 18))

function e3({x}: { x?: number }) { }  // x is an optional with type number
>e3 : Symbol(e3, Decl(destructuringParameterDeclaration1ES5.ts, 92, 35))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 93, 13))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 93, 18))

function e4({x: [number,string,any] }) { }  // x has type [any, any, any]
>e4 : Symbol(e4, Decl(destructuringParameterDeclaration1ES5.ts, 93, 36))
>x : Symbol(x)
>number : Symbol(number, Decl(destructuringParameterDeclaration1ES5.ts, 94, 17))
>string : Symbol(string, Decl(destructuringParameterDeclaration1ES5.ts, 94, 24))
>any : Symbol(any, Decl(destructuringParameterDeclaration1ES5.ts, 94, 31))

function e5({x: [a, b, c]}: { x: [number, number, number] }) { }  // x has type [any, any, any]
>e5 : Symbol(e5, Decl(destructuringParameterDeclaration1ES5.ts, 94, 42))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 95, 29))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES5.ts, 95, 17))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES5.ts, 95, 19))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES5.ts, 95, 22))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES5.ts, 95, 29))

