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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
=== tests/cases/compiler/computedPropertiesInDestructuring1.ts ===
// destructuring in variable declarations
let foo = "bar";
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
let {[foo]: bar} = {bar: "bar"};
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 2, 5))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 2, 20))
let {["bar"]: bar2} = {bar: "bar"};
>"bar" : Symbol(bar2, Decl(computedPropertiesInDestructuring1.ts, 4, 5))
>bar2 : Symbol(bar2, Decl(computedPropertiesInDestructuring1.ts, 4, 5))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 4, 23))
let foo2 = () => "bar";
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1.ts, 6, 3))
let {[foo2()]: bar3} = {bar: "bar"};
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1.ts, 6, 3))
>bar3 : Symbol(bar3, Decl(computedPropertiesInDestructuring1.ts, 7, 5))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 7, 24))
let [{[foo]: bar4}] = [{bar: "bar"}];
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>bar4 : Symbol(bar4, Decl(computedPropertiesInDestructuring1.ts, 9, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 9, 24))
let [{[foo2()]: bar5}] = [{bar: "bar"}];
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1.ts, 6, 3))
>bar5 : Symbol(bar5, Decl(computedPropertiesInDestructuring1.ts, 10, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 10, 27))
function f1({["bar"]: x}: { bar: number }) {}
>f1 : Symbol(f1, Decl(computedPropertiesInDestructuring1.ts, 10, 40))
>"bar" : Symbol(x, Decl(computedPropertiesInDestructuring1.ts, 12, 13))
>x : Symbol(x, Decl(computedPropertiesInDestructuring1.ts, 12, 13))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 12, 27))
function f2({[foo]: x}: { bar: number }) {}
>f2 : Symbol(f2, Decl(computedPropertiesInDestructuring1.ts, 12, 45))
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>x : Symbol(x, Decl(computedPropertiesInDestructuring1.ts, 13, 13))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 13, 25))
function f3({[foo2()]: x}: { bar: number }) {}
>f3 : Symbol(f3, Decl(computedPropertiesInDestructuring1.ts, 13, 43))
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1.ts, 6, 3))
>x : Symbol(x, Decl(computedPropertiesInDestructuring1.ts, 14, 13))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 14, 28))
function f4([{[foo]: x}]: [{ bar: number }]) {}
>f4 : Symbol(f4, Decl(computedPropertiesInDestructuring1.ts, 14, 46))
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>x : Symbol(x, Decl(computedPropertiesInDestructuring1.ts, 15, 14))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 15, 28))
function f5([{[foo2()]: x}]: [{ bar: number }]) {}
>f5 : Symbol(f5, Decl(computedPropertiesInDestructuring1.ts, 15, 47))
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1.ts, 6, 3))
>x : Symbol(x, Decl(computedPropertiesInDestructuring1.ts, 16, 14))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 16, 31))
// report errors on type errors in computed properties used in destructuring
let [{[foo()]: bar6}] = [{bar: "bar"}];
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>bar6 : Symbol(bar6, Decl(computedPropertiesInDestructuring1.ts, 19, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 19, 26))
let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}];
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>bar7 : Symbol(bar7, Decl(computedPropertiesInDestructuring1.ts, 20, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 20, 40))
// destructuring assignment
({[foo]: bar} = {bar: "bar"});
>[foo] : Symbol([foo], Decl(computedPropertiesInDestructuring1.ts, 23, 2))
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 2, 5))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 23, 17))
({["bar"]: bar2} = {bar: "bar"});
>["bar"] : Symbol(["bar"], Decl(computedPropertiesInDestructuring1.ts, 25, 2))
>"bar" : Symbol(["bar"], Decl(computedPropertiesInDestructuring1.ts, 25, 2))
>bar2 : Symbol(bar2, Decl(computedPropertiesInDestructuring1.ts, 4, 5))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 25, 20))
({[foo2()]: bar3} = {bar: "bar"});
>[foo2()] : Symbol([foo2()], Decl(computedPropertiesInDestructuring1.ts, 27, 2))
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1.ts, 6, 3))
>bar3 : Symbol(bar3, Decl(computedPropertiesInDestructuring1.ts, 7, 5))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 27, 21))
[{[foo]: bar4}] = [{bar: "bar"}];
>[foo] : Symbol([foo], Decl(computedPropertiesInDestructuring1.ts, 29, 2))
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>bar4 : Symbol(bar4, Decl(computedPropertiesInDestructuring1.ts, 9, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 29, 20))
[{[foo2()]: bar5}] = [{bar: "bar"}];
>[foo2()] : Symbol([foo2()], Decl(computedPropertiesInDestructuring1.ts, 30, 2))
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1.ts, 6, 3))
>bar5 : Symbol(bar5, Decl(computedPropertiesInDestructuring1.ts, 10, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 30, 23))
[{[foo()]: bar4}] = [{bar: "bar"}];
>[foo()] : Symbol([foo()], Decl(computedPropertiesInDestructuring1.ts, 32, 2))
>foo : Symbol(foo, Decl(computedPropertiesInDestructuring1.ts, 1, 3))
>bar4 : Symbol(bar4, Decl(computedPropertiesInDestructuring1.ts, 9, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 32, 22))
[{[(1 + {})]: bar4}] = [{bar: "bar"}];
>[(1 + {})] : Symbol([(1 + {})], Decl(computedPropertiesInDestructuring1.ts, 33, 2))
>bar4 : Symbol(bar4, Decl(computedPropertiesInDestructuring1.ts, 9, 6))
>bar : Symbol(bar, Decl(computedPropertiesInDestructuring1.ts, 33, 25))
|