=== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6.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 : number 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" : string var {1: b3} = { 1: "string" }; >b3 : string >{ 1: "string" } : { 1: string; } >"string" : string var {b4 = 1}: any = { b4: 100000 }; >b4 : number >1 : number >{ b4: 100000 } : { b4: number; } >b4 : number >100000 : number 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 { >F : F [idx: number]: boolean; >idx : number } function foo(): F { >foo : () => F >F : F return { >{ 1: true } : { [x: number]: boolean; 1: boolean; } 1: true >true : boolean }; } function bar(): F { >bar : () => F >F : F return { >{ 2: true } : { [x: number]: boolean; 2: boolean; } 2: true >true : boolean }; } 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 { >F1 : F1 [str: string]: number; >str : string } function foo1(): F1 { >foo1 : () => F1 >F1 : F1 return { >{ "prop1": 2 } : { [x: string]: number; "prop1": number; } "prop1": 2 >2 : number } } var {"prop1": d1} = foo1(); >d1 : number >foo1() : F1 >foo1 : () => F1 var {"prop2": d1} = foo1(); >d1 : number >foo1() : F1 >foo1 : () => F1