|
| 1 | +=== tests/cases/conformance/types/intersection/intersectionOfUnionNarrowing.ts === |
| 2 | +interface X { |
| 3 | +>X : Symbol(X, Decl(intersectionOfUnionNarrowing.ts, 0, 0)) |
| 4 | + |
| 5 | + a?: { aProp: string }; |
| 6 | +>a : Symbol(X.a, Decl(intersectionOfUnionNarrowing.ts, 0, 13)) |
| 7 | +>aProp : Symbol(aProp, Decl(intersectionOfUnionNarrowing.ts, 1, 7)) |
| 8 | + |
| 9 | + b?: { bProp: string }; |
| 10 | +>b : Symbol(X.b, Decl(intersectionOfUnionNarrowing.ts, 1, 24)) |
| 11 | +>bProp : Symbol(bProp, Decl(intersectionOfUnionNarrowing.ts, 2, 7)) |
| 12 | +} |
| 13 | +type AorB = { a: object; b: undefined } | { a: undefined; b: object }; |
| 14 | +>AorB : Symbol(AorB, Decl(intersectionOfUnionNarrowing.ts, 3, 1)) |
| 15 | +>a : Symbol(a, Decl(intersectionOfUnionNarrowing.ts, 4, 13)) |
| 16 | +>b : Symbol(b, Decl(intersectionOfUnionNarrowing.ts, 4, 24)) |
| 17 | +>a : Symbol(a, Decl(intersectionOfUnionNarrowing.ts, 4, 43)) |
| 18 | +>b : Symbol(b, Decl(intersectionOfUnionNarrowing.ts, 4, 57)) |
| 19 | + |
| 20 | +declare const q: X & AorB; |
| 21 | +>q : Symbol(q, Decl(intersectionOfUnionNarrowing.ts, 6, 13)) |
| 22 | +>X : Symbol(X, Decl(intersectionOfUnionNarrowing.ts, 0, 0)) |
| 23 | +>AorB : Symbol(AorB, Decl(intersectionOfUnionNarrowing.ts, 3, 1)) |
| 24 | + |
| 25 | +if (q.a !== undefined) { |
| 26 | +>q.a : Symbol(a, Decl(intersectionOfUnionNarrowing.ts, 0, 13), Decl(intersectionOfUnionNarrowing.ts, 4, 13), Decl(intersectionOfUnionNarrowing.ts, 0, 13), Decl(intersectionOfUnionNarrowing.ts, 4, 43)) |
| 27 | +>q : Symbol(q, Decl(intersectionOfUnionNarrowing.ts, 6, 13)) |
| 28 | +>a : Symbol(a, Decl(intersectionOfUnionNarrowing.ts, 0, 13), Decl(intersectionOfUnionNarrowing.ts, 4, 13), Decl(intersectionOfUnionNarrowing.ts, 0, 13), Decl(intersectionOfUnionNarrowing.ts, 4, 43)) |
| 29 | +>undefined : Symbol(undefined) |
| 30 | + |
| 31 | + q.a.aProp; |
| 32 | +>q.a.aProp : Symbol(aProp, Decl(intersectionOfUnionNarrowing.ts, 1, 7)) |
| 33 | +>q.a : Symbol(a, Decl(intersectionOfUnionNarrowing.ts, 0, 13), Decl(intersectionOfUnionNarrowing.ts, 4, 13)) |
| 34 | +>q : Symbol(q, Decl(intersectionOfUnionNarrowing.ts, 6, 13)) |
| 35 | +>a : Symbol(a, Decl(intersectionOfUnionNarrowing.ts, 0, 13), Decl(intersectionOfUnionNarrowing.ts, 4, 13)) |
| 36 | +>aProp : Symbol(aProp, Decl(intersectionOfUnionNarrowing.ts, 1, 7)) |
| 37 | + |
| 38 | +} else { |
| 39 | + // q.b is previously incorrectly inferred as potentially undefined |
| 40 | + q.b.bProp; |
| 41 | +>q.b.bProp : Symbol(bProp, Decl(intersectionOfUnionNarrowing.ts, 2, 7)) |
| 42 | +>q.b : Symbol(b, Decl(intersectionOfUnionNarrowing.ts, 1, 24), Decl(intersectionOfUnionNarrowing.ts, 4, 57)) |
| 43 | +>q : Symbol(q, Decl(intersectionOfUnionNarrowing.ts, 6, 13)) |
| 44 | +>b : Symbol(b, Decl(intersectionOfUnionNarrowing.ts, 1, 24), Decl(intersectionOfUnionNarrowing.ts, 4, 57)) |
| 45 | +>bProp : Symbol(bProp, Decl(intersectionOfUnionNarrowing.ts, 2, 7)) |
| 46 | +} |
| 47 | + |
0 commit comments