I think typeof undefined checks should not error in the last accessor of the expression. Because I'm already checking for undefined:
So below code should be perfectly fine:
interface A {
a: string;
}
interface B {
b: string;
}
function isA(x: A | B): x is A {
return typeof x.a !== 'undefined'; // Error in "a" does not exists
}
Right now, I have to type assert x to any.
I think
typeof undefinedchecks should not error in the last accessor of the expression. Because I'm already checking forundefined:So below code should be perfectly fine:
Right now, I have to type assert
xto any.