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

=== destructuringObjectBindingPatternAndAssignment1ES5.ts ===
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
// An expression of type S is considered assignable to an assignment target V if one of the following is true

// V is an object assignment pattern and, for each assignment property P in V,
//      S is the type Any, or
var { a1 }: any = undefined;
>a1 : any
>   : ^^^
>undefined : undefined
>          : ^^^^^^^^^

var { a2 }: any = {};
>a2 : any
>   : ^^^
>{} : {}
>   : ^^

// V is an object assignment pattern and, for each assignment property P in V,
//      S has an apparent property with the property name specified in
//          P of a type that is assignable to the target given in P, or
var { b1, } = { b1:1, };
>b1 : number
>   : ^^^^^^
>{ b1:1, } : { b1: number; }
>          : ^^^^^^^^^^^^^^^
>b1 : number
>   : ^^^^^^
>1 : 1
>  : ^

var { b2: { b21 } = { b21: "string" }  } = { b2: { b21: "world" } };
>b2 : any
>   : ^^^
>b21 : string
>    : ^^^^^^
>{ b21: "string" } : { b21: string; }
>                  : ^^^^^^^^^^^^^^^^
>b21 : string
>    : ^^^^^^
>"string" : "string"
>         : ^^^^^^^^
>{ b2: { b21: "world" } } : { b2?: { b21: string; }; }
>                         : ^^^^^^^^^^^^^^^^^^^^^^^^^^
>b2 : { b21: string; }
>   : ^^^^^^^^^^^^^^^^
>{ b21: "world" } : { b21: string; }
>                 : ^^^^^^^^^^^^^^^^
>b21 : string
>    : ^^^^^^
>"world" : "world"
>        : ^^^^^^^

var {1: b3} = { 1: "string" };
>b3 : string
>   : ^^^^^^
>{ 1: "string" } : { 1: string; }
>                : ^^^^^^^^^^^^^^
>1 : string
>  : ^^^^^^
>"string" : "string"
>         : ^^^^^^^^

var {b4 = 1}: any = { b4: 100000 };
>b4 : any
>   : ^^^
>1 : 1
>  : ^
>{ b4: 100000 } : { b4: number; }
>               : ^^^^^^^^^^^^^^^
>b4 : number
>   : ^^^^^^
>100000 : 100000
>       : ^^^^^^

var {b5: { b52 }  } = { b5: { b52 } };
>b5 : any
>   : ^^^
>b52 : any
>    : ^^^
>{ b5: { b52 } } : { b5: { b52: any; }; }
>                : ^^^^^^^^^^^^^^^^^^^^^^
>b5 : { b52: any; }
>   : ^^^^^^^^^^^^^
>{ b52 } : { b52: any; }
>        : ^^^^^^^^^^^^^
>b52 : any

// V is an object assignment pattern and, for each assignment property P in V,
//      P specifies a numeric property name and S has a numeric index signature
//          of a type that is assignable to the target given in P, or

interface F {
    [idx: number]: boolean;
>idx : number
>    : ^^^^^^
}

function foo(): F {
>foo : () => F
>    : ^^^^^^ 

    return {
>{        1: true    } : { 1: true; }
>                      : ^^^^^^^^^^^^

        1: true
>1 : true
>  : ^^^^
>true : true
>     : ^^^^

    };
}

function bar(): F {
>bar : () => F
>    : ^^^^^^ 

    return {
>{        2: true    } : { 2: true; }
>                      : ^^^^^^^^^^^^

        2: true
>2 : true
>  : ^^^^
>true : true
>     : ^^^^

    };
}
var {1: c0} = foo();
>c0 : boolean
>   : ^^^^^^^
>foo() : F
>      : ^
>foo : () => F
>    : ^^^^^^ 

var {1: c1} = bar();
>c1 : boolean
>   : ^^^^^^^
>bar() : F
>      : ^
>bar : () => F
>    : ^^^^^^ 

// V is an object assignment pattern and, for each assignment property P in V,
//      S has a string index signature of a type that is assignable to the target given in P

interface F1 {
    [str: string]: number;
>str : string
>    : ^^^^^^
}

function foo1(): F1 {
>foo1 : () => F1
>     : ^^^^^^  

    return {
>{        "prop1": 2    } : { prop1: number; }
>                         : ^^^^^^^^^^^^^^^^^^

        "prop1": 2
>"prop1" : number
>        : ^^^^^^
>2 : 2
>  : ^
    }
}

var {"prop1": d1} = foo1();
>d1 : number
>   : ^^^^^^
>foo1() : F1
>       : ^^
>foo1 : () => F1
>     : ^^^^^^  

var {"prop2": d1} = foo1();
>d1 : number
>   : ^^^^^^
>foo1() : F1
>       : ^^
>foo1 : () => F1
>     : ^^^^^^  

