TypeScript Version: 2.1.1
Code
type A = { a: string; }
type B = { b: string; }
type AorB = A | B;
declare const AorB: AorB;
if (AorB.a) {
// use AorB.a
}
Expected behavior:
The code compiles without errors. Even though a doesn't (necessarily) exist on all the constituents of the union, the fact that it exists on some should allow me to check for .a and use it if it is present.
Actual behavior:
Typescript complains: "Property a does not exist on type AorB... Property a does not exist on type B."