|
| 1 | +=== tests/cases/compiler/narrowingTypeofUndefined1.ts === |
| 2 | +declare const a: { error: { prop: string }, result: undefined } | { error: undefined, result: { prop: number } } |
| 3 | +>a : Symbol(a, Decl(narrowingTypeofUndefined1.ts, 0, 13)) |
| 4 | +>error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18)) |
| 5 | +>prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 27)) |
| 6 | +>result : Symbol(result, Decl(narrowingTypeofUndefined1.ts, 0, 43)) |
| 7 | +>error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 8 | +>result : Symbol(result, Decl(narrowingTypeofUndefined1.ts, 0, 85)) |
| 9 | +>prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 95)) |
| 10 | + |
| 11 | +if (typeof a.error === 'undefined') { |
| 12 | +>a.error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 13 | +>a : Symbol(a, Decl(narrowingTypeofUndefined1.ts, 0, 13)) |
| 14 | +>error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 15 | + |
| 16 | + a.result.prop; // number |
| 17 | +>a.result.prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 95)) |
| 18 | +>a.result : Symbol(result, Decl(narrowingTypeofUndefined1.ts, 0, 43), Decl(narrowingTypeofUndefined1.ts, 0, 85)) |
| 19 | +>a : Symbol(a, Decl(narrowingTypeofUndefined1.ts, 0, 13)) |
| 20 | +>result : Symbol(result, Decl(narrowingTypeofUndefined1.ts, 0, 43), Decl(narrowingTypeofUndefined1.ts, 0, 85)) |
| 21 | +>prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 95)) |
| 22 | +} |
| 23 | +else { |
| 24 | + a.error.prop; // string |
| 25 | +>a.error.prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 27)) |
| 26 | +>a.error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 27 | +>a : Symbol(a, Decl(narrowingTypeofUndefined1.ts, 0, 13)) |
| 28 | +>error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 29 | +>prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 27)) |
| 30 | +} |
| 31 | + |
| 32 | +if (typeof a.error !== 'undefined') { |
| 33 | +>a.error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 34 | +>a : Symbol(a, Decl(narrowingTypeofUndefined1.ts, 0, 13)) |
| 35 | +>error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 36 | + |
| 37 | + a.error.prop; // string |
| 38 | +>a.error.prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 27)) |
| 39 | +>a.error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 40 | +>a : Symbol(a, Decl(narrowingTypeofUndefined1.ts, 0, 13)) |
| 41 | +>error : Symbol(error, Decl(narrowingTypeofUndefined1.ts, 0, 18), Decl(narrowingTypeofUndefined1.ts, 0, 67)) |
| 42 | +>prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 27)) |
| 43 | +} |
| 44 | +else { |
| 45 | + a.result.prop; // number |
| 46 | +>a.result.prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 95)) |
| 47 | +>a.result : Symbol(result, Decl(narrowingTypeofUndefined1.ts, 0, 43), Decl(narrowingTypeofUndefined1.ts, 0, 85)) |
| 48 | +>a : Symbol(a, Decl(narrowingTypeofUndefined1.ts, 0, 13)) |
| 49 | +>result : Symbol(result, Decl(narrowingTypeofUndefined1.ts, 0, 43), Decl(narrowingTypeofUndefined1.ts, 0, 85)) |
| 50 | +>prop : Symbol(prop, Decl(narrowingTypeofUndefined1.ts, 0, 95)) |
| 51 | +} |
| 52 | + |
0 commit comments