swc/crates/swc_ecma_parser/tests/tsc/intersectionOfUnionNarrowing.ts
2022-02-04 17:08:38 +09:00

17 lines
315 B
TypeScript

// @strict: true
interface X {
a?: { aProp: string };
b?: { bProp: string };
}
type AorB = { a: object; b: undefined } | { a: undefined; b: object };
declare const q: X & AorB;
if (q.a !== undefined) {
q.a.aProp;
} else {
// q.b is previously incorrectly inferred as potentially undefined
q.b.bProp;
}