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
interfaceA{f?: number;bar: string;}interfaceB{f: number;}declareconstx: A|B;if(x.f==undefined){//Expected://'x' is narrowed to type 'A'//Actual://Property 'bar' does not exist on type 'A | B'.//Property 'bar' does not exist on type 'B'.console.log(x.bar);}
Expected behavior:
'x' is narrowed to type 'A'
Actual behavior:
Property 'bar' does not exist on type 'A | B'.
Property 'bar' does not exist on type 'B'.
TypeScript Version: 3.0.0-dev.20180602
Search Terms: field type guard narrow
Code
Expected behavior:
'x' is narrowed to type 'A'
Actual behavior:
Playground Link: Here
The text was updated successfully, but these errors were encountered: