You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeA={a: string;}typeB={b: string;}typeAorB=A|B;declareconstAorB: 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."
Elijen, davl3232, nikojpapa, thibautsabot, jannikbuschke and 90 more