1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
=== tests/cases/compiler/restElementAssignable.ts ===
{
const { ...props } = {};
>props : {}
>{} : {}
// Use to fail
const t1: { [x: symbol]: unknown } = props;
>t1 : { [x: symbol]: unknown; }
>x : symbol
>props : {}
// Working equivalent
const t2: { [x: symbol]: unknown } = {};
>t2 : { [x: symbol]: unknown; }
>x : symbol
>{} : {}
}
{
const { ...props } = { a: 1, b: false, c: "str" };
>props : { a: number; b: boolean; c: string; }
>{ a: 1, b: false, c: "str" } : { a: number; b: boolean; c: string; }
>a : number
>1 : 1
>b : boolean
>false : false
>c : string
>"str" : "str"
// Use to fail
const t1: { [x: string]: number | boolean | string } = props;
>t1 : { [x: string]: string | number | boolean; }
>x : string
>props : { a: number; b: boolean; c: string; }
// Working equivalent
const t2: { [x: string]: number | boolean | string } = { a: 1, b: false, c: "str" };;
>t2 : { [x: string]: string | number | boolean; }
>x : string
>{ a: 1, b: false, c: "str" } : { a: number; b: false; c: string; }
>a : number
>1 : 1
>b : false
>false : false
>c : string
>"str" : "str"
}
|