|
| 1 | +=== tests/cases/compiler/destructuringTypeGuardFlow.ts === |
| 2 | +type foo = { |
| 3 | +>foo : Symbol(foo, Decl(destructuringTypeGuardFlow.ts, 0, 0)) |
| 4 | + |
| 5 | + bar: number | null; |
| 6 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 7 | + |
| 8 | + baz: string; |
| 9 | +>baz : Symbol(baz, Decl(destructuringTypeGuardFlow.ts, 1, 21)) |
| 10 | + |
| 11 | + nested: { |
| 12 | +>nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 2, 14)) |
| 13 | + |
| 14 | + a: number; |
| 15 | +>a : Symbol(a, Decl(destructuringTypeGuardFlow.ts, 3, 11)) |
| 16 | + |
| 17 | + b: string | null; |
| 18 | +>b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 4, 14)) |
| 19 | + } |
| 20 | +}; |
| 21 | + |
| 22 | +const aFoo: foo = { bar: 3, baz: "b", nested: { a: 1, b: "y" } }; |
| 23 | +>aFoo : Symbol(aFoo, Decl(destructuringTypeGuardFlow.ts, 9, 5)) |
| 24 | +>foo : Symbol(foo, Decl(destructuringTypeGuardFlow.ts, 0, 0)) |
| 25 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 9, 19)) |
| 26 | +>baz : Symbol(baz, Decl(destructuringTypeGuardFlow.ts, 9, 27)) |
| 27 | +>nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 9, 37)) |
| 28 | +>a : Symbol(a, Decl(destructuringTypeGuardFlow.ts, 9, 47)) |
| 29 | +>b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 9, 53)) |
| 30 | + |
| 31 | +if (aFoo.bar && aFoo.nested.b) { |
| 32 | +>aFoo.bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 33 | +>aFoo : Symbol(aFoo, Decl(destructuringTypeGuardFlow.ts, 9, 5)) |
| 34 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 35 | +>aFoo.nested.b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 4, 14)) |
| 36 | +>aFoo.nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 2, 14)) |
| 37 | +>aFoo : Symbol(aFoo, Decl(destructuringTypeGuardFlow.ts, 9, 5)) |
| 38 | +>nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 2, 14)) |
| 39 | +>b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 4, 14)) |
| 40 | + |
| 41 | + const { bar, baz, nested: {a, b: text} } = aFoo; |
| 42 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 12, 9)) |
| 43 | +>baz : Symbol(baz, Decl(destructuringTypeGuardFlow.ts, 12, 14)) |
| 44 | +>nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 2, 14)) |
| 45 | +>a : Symbol(a, Decl(destructuringTypeGuardFlow.ts, 12, 29)) |
| 46 | +>b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 4, 14)) |
| 47 | +>text : Symbol(text, Decl(destructuringTypeGuardFlow.ts, 12, 31)) |
| 48 | +>aFoo : Symbol(aFoo, Decl(destructuringTypeGuardFlow.ts, 9, 5)) |
| 49 | + |
| 50 | + const right: number = aFoo.bar; |
| 51 | +>right : Symbol(right, Decl(destructuringTypeGuardFlow.ts, 13, 7)) |
| 52 | +>aFoo.bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 53 | +>aFoo : Symbol(aFoo, Decl(destructuringTypeGuardFlow.ts, 9, 5)) |
| 54 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 55 | + |
| 56 | + const wrong: number = bar; |
| 57 | +>wrong : Symbol(wrong, Decl(destructuringTypeGuardFlow.ts, 14, 7)) |
| 58 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 12, 9)) |
| 59 | + |
| 60 | + const another: string = baz; |
| 61 | +>another : Symbol(another, Decl(destructuringTypeGuardFlow.ts, 15, 7)) |
| 62 | +>baz : Symbol(baz, Decl(destructuringTypeGuardFlow.ts, 12, 14)) |
| 63 | + |
| 64 | + const aAgain: number = a; |
| 65 | +>aAgain : Symbol(aAgain, Decl(destructuringTypeGuardFlow.ts, 16, 7)) |
| 66 | +>a : Symbol(a, Decl(destructuringTypeGuardFlow.ts, 12, 29)) |
| 67 | + |
| 68 | + const bAgain: string = text; |
| 69 | +>bAgain : Symbol(bAgain, Decl(destructuringTypeGuardFlow.ts, 17, 7)) |
| 70 | +>text : Symbol(text, Decl(destructuringTypeGuardFlow.ts, 12, 31)) |
| 71 | +} |
| 72 | + |
| 73 | +type bar = { |
| 74 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 18, 1)) |
| 75 | + |
| 76 | + elem1: number | null; |
| 77 | +>elem1 : Symbol(elem1, Decl(destructuringTypeGuardFlow.ts, 20, 12)) |
| 78 | + |
| 79 | + elem2: foo | null; |
| 80 | +>elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 21, 23)) |
| 81 | +>foo : Symbol(foo, Decl(destructuringTypeGuardFlow.ts, 0, 0)) |
| 82 | + |
| 83 | +}; |
| 84 | + |
| 85 | +const bBar = { elem1: 7, elem2: aFoo }; |
| 86 | +>bBar : Symbol(bBar, Decl(destructuringTypeGuardFlow.ts, 25, 5)) |
| 87 | +>elem1 : Symbol(elem1, Decl(destructuringTypeGuardFlow.ts, 25, 14)) |
| 88 | +>elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 89 | +>aFoo : Symbol(aFoo, Decl(destructuringTypeGuardFlow.ts, 9, 5)) |
| 90 | + |
| 91 | +if (bBar.elem2 && bBar.elem2.bar && bBar.elem2.nested.b) { |
| 92 | +>bBar.elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 93 | +>bBar : Symbol(bBar, Decl(destructuringTypeGuardFlow.ts, 25, 5)) |
| 94 | +>elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 95 | +>bBar.elem2.bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 96 | +>bBar.elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 97 | +>bBar : Symbol(bBar, Decl(destructuringTypeGuardFlow.ts, 25, 5)) |
| 98 | +>elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 99 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 100 | +>bBar.elem2.nested.b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 4, 14)) |
| 101 | +>bBar.elem2.nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 2, 14)) |
| 102 | +>bBar.elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 103 | +>bBar : Symbol(bBar, Decl(destructuringTypeGuardFlow.ts, 25, 5)) |
| 104 | +>elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 105 | +>nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 2, 14)) |
| 106 | +>b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 4, 14)) |
| 107 | + |
| 108 | + const { bar, baz, nested: {a, b: text} } = bBar.elem2; |
| 109 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 28, 9)) |
| 110 | +>baz : Symbol(baz, Decl(destructuringTypeGuardFlow.ts, 28, 14)) |
| 111 | +>nested : Symbol(nested, Decl(destructuringTypeGuardFlow.ts, 2, 14)) |
| 112 | +>a : Symbol(a, Decl(destructuringTypeGuardFlow.ts, 28, 29)) |
| 113 | +>b : Symbol(b, Decl(destructuringTypeGuardFlow.ts, 4, 14)) |
| 114 | +>text : Symbol(text, Decl(destructuringTypeGuardFlow.ts, 28, 31)) |
| 115 | +>bBar.elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 116 | +>bBar : Symbol(bBar, Decl(destructuringTypeGuardFlow.ts, 25, 5)) |
| 117 | +>elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 118 | + |
| 119 | + const right: number = bBar.elem2.bar; |
| 120 | +>right : Symbol(right, Decl(destructuringTypeGuardFlow.ts, 29, 7)) |
| 121 | +>bBar.elem2.bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 122 | +>bBar.elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 123 | +>bBar : Symbol(bBar, Decl(destructuringTypeGuardFlow.ts, 25, 5)) |
| 124 | +>elem2 : Symbol(elem2, Decl(destructuringTypeGuardFlow.ts, 25, 24)) |
| 125 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 0, 12)) |
| 126 | + |
| 127 | + const wrong: number = bar; |
| 128 | +>wrong : Symbol(wrong, Decl(destructuringTypeGuardFlow.ts, 30, 7)) |
| 129 | +>bar : Symbol(bar, Decl(destructuringTypeGuardFlow.ts, 28, 9)) |
| 130 | + |
| 131 | + const another: string = baz; |
| 132 | +>another : Symbol(another, Decl(destructuringTypeGuardFlow.ts, 31, 7)) |
| 133 | +>baz : Symbol(baz, Decl(destructuringTypeGuardFlow.ts, 28, 14)) |
| 134 | + |
| 135 | + const aAgain: number = a; |
| 136 | +>aAgain : Symbol(aAgain, Decl(destructuringTypeGuardFlow.ts, 32, 7)) |
| 137 | +>a : Symbol(a, Decl(destructuringTypeGuardFlow.ts, 28, 29)) |
| 138 | + |
| 139 | + const bAgain: string = text; |
| 140 | +>bAgain : Symbol(bAgain, Decl(destructuringTypeGuardFlow.ts, 33, 7)) |
| 141 | +>text : Symbol(text, Decl(destructuringTypeGuardFlow.ts, 28, 31)) |
| 142 | +} |
| 143 | + |
0 commit comments