|
| 1 | +=== tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts === |
| 2 | +function f1(obj: { a?: string }) { |
| 3 | +>f1 : Symbol(f1, Decl(destructuringControlFlow.ts, 0, 0)) |
| 4 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12)) |
| 5 | +>a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18)) |
| 6 | + |
| 7 | + if (obj.a) { |
| 8 | +>obj.a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18)) |
| 9 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12)) |
| 10 | +>a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18)) |
| 11 | + |
| 12 | + obj = {}; |
| 13 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12)) |
| 14 | + |
| 15 | + let a1 = obj["a"]; // string | undefined |
| 16 | +>a1 : Symbol(a1, Decl(destructuringControlFlow.ts, 3, 11)) |
| 17 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12)) |
| 18 | +>"a" : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18)) |
| 19 | + |
| 20 | + let a2 = obj.a; // string | undefined |
| 21 | +>a2 : Symbol(a2, Decl(destructuringControlFlow.ts, 4, 11)) |
| 22 | +>obj.a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18)) |
| 23 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12)) |
| 24 | +>a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18)) |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +function f2(obj: [number, string] | null[]) { |
| 29 | +>f2 : Symbol(f2, Decl(destructuringControlFlow.ts, 6, 1)) |
| 30 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 31 | + |
| 32 | + let a0 = obj[0]; // number | null |
| 33 | +>a0 : Symbol(a0, Decl(destructuringControlFlow.ts, 9, 7)) |
| 34 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 35 | +>0 : Symbol(0) |
| 36 | + |
| 37 | + let a1 = obj[1]; // string | null |
| 38 | +>a1 : Symbol(a1, Decl(destructuringControlFlow.ts, 10, 7)) |
| 39 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 40 | +>1 : Symbol(1) |
| 41 | + |
| 42 | + let [b0, b1] = obj; |
| 43 | +>b0 : Symbol(b0, Decl(destructuringControlFlow.ts, 11, 9)) |
| 44 | +>b1 : Symbol(b1, Decl(destructuringControlFlow.ts, 11, 12)) |
| 45 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 46 | + |
| 47 | + ([a0, a1] = obj); |
| 48 | +>a0 : Symbol(a0, Decl(destructuringControlFlow.ts, 9, 7)) |
| 49 | +>a1 : Symbol(a1, Decl(destructuringControlFlow.ts, 10, 7)) |
| 50 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 51 | + |
| 52 | + if (obj[0] && obj[1]) { |
| 53 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 54 | +>0 : Symbol(0) |
| 55 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 56 | +>1 : Symbol(1) |
| 57 | + |
| 58 | + let c0 = obj[0]; // number |
| 59 | +>c0 : Symbol(c0, Decl(destructuringControlFlow.ts, 14, 11)) |
| 60 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 61 | +>0 : Symbol(0) |
| 62 | + |
| 63 | + let c1 = obj[1]; // string |
| 64 | +>c1 : Symbol(c1, Decl(destructuringControlFlow.ts, 15, 11)) |
| 65 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 66 | +>1 : Symbol(1) |
| 67 | + |
| 68 | + let [d0, d1] = obj; |
| 69 | +>d0 : Symbol(d0, Decl(destructuringControlFlow.ts, 16, 13)) |
| 70 | +>d1 : Symbol(d1, Decl(destructuringControlFlow.ts, 16, 16)) |
| 71 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 72 | + |
| 73 | + ([c0, c1] = obj); |
| 74 | +>c0 : Symbol(c0, Decl(destructuringControlFlow.ts, 14, 11)) |
| 75 | +>c1 : Symbol(c1, Decl(destructuringControlFlow.ts, 15, 11)) |
| 76 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12)) |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +function f3(obj: { a?: number, b?: string }) { |
| 81 | +>f3 : Symbol(f3, Decl(destructuringControlFlow.ts, 19, 1)) |
| 82 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12)) |
| 83 | +>a : Symbol(a, Decl(destructuringControlFlow.ts, 21, 18)) |
| 84 | +>b : Symbol(b, Decl(destructuringControlFlow.ts, 21, 30)) |
| 85 | + |
| 86 | + if (obj.a && obj.b) { |
| 87 | +>obj.a : Symbol(a, Decl(destructuringControlFlow.ts, 21, 18)) |
| 88 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12)) |
| 89 | +>a : Symbol(a, Decl(destructuringControlFlow.ts, 21, 18)) |
| 90 | +>obj.b : Symbol(b, Decl(destructuringControlFlow.ts, 21, 30)) |
| 91 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12)) |
| 92 | +>b : Symbol(b, Decl(destructuringControlFlow.ts, 21, 30)) |
| 93 | + |
| 94 | + let { a, b } = obj; // number, string |
| 95 | +>a : Symbol(a, Decl(destructuringControlFlow.ts, 23, 13)) |
| 96 | +>b : Symbol(b, Decl(destructuringControlFlow.ts, 23, 16)) |
| 97 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12)) |
| 98 | + |
| 99 | + ({ a, b } = obj); |
| 100 | +>a : Symbol(a, Decl(destructuringControlFlow.ts, 24, 10)) |
| 101 | +>b : Symbol(b, Decl(destructuringControlFlow.ts, 24, 13)) |
| 102 | +>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12)) |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +function f4() { |
| 107 | +>f4 : Symbol(f4, Decl(destructuringControlFlow.ts, 26, 1)) |
| 108 | + |
| 109 | + let x: boolean; |
| 110 | +>x : Symbol(x, Decl(destructuringControlFlow.ts, 29, 7)) |
| 111 | + |
| 112 | + ({ x } = 0); // Error |
| 113 | +>x : Symbol(x, Decl(destructuringControlFlow.ts, 30, 6)) |
| 114 | + |
| 115 | + ({ ["x"]: x } = 0); // Error |
| 116 | +>["x"] : Symbol(["x"], Decl(destructuringControlFlow.ts, 31, 6)) |
| 117 | +>"x" : Symbol(["x"], Decl(destructuringControlFlow.ts, 31, 6)) |
| 118 | +>x : Symbol(x, Decl(destructuringControlFlow.ts, 29, 7)) |
| 119 | + |
| 120 | + ({ ["x" + ""]: x } = 0); // Errpr |
| 121 | +>["x" + ""] : Symbol(["x" + ""], Decl(destructuringControlFlow.ts, 32, 6)) |
| 122 | +>x : Symbol(x, Decl(destructuringControlFlow.ts, 29, 7)) |
| 123 | +} |
| 124 | + |
0 commit comments