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
interfaceFoo{property: (boolean|{bar: number})}varfoo: Foo={property: {bar: 123}};varp=foo.property;if(typeofp==='object'){// This works fine!console.log(p.bar);// Prints "123"}if(typeoffoo.property==='object'){// This line produces the following compilation error:// "Property 'bar' does not exist on type 'boolean | { bar: number; }'"console.log(foo.property.bar);}
Expected behavior:
I expected if (typeof foo.property === 'object') { to be a valid type guard.
Actual behavior:
It's not.
The text was updated successfully, but these errors were encountered:
TypeScript Version:
1.8.2
Code
Expected behavior:
I expected
if (typeof foo.property === 'object') {
to be a valid type guard.Actual behavior:
It's not.
The text was updated successfully, but these errors were encountered: