Closed
Description
I have three checks in a "&&" chain. The order of the first two checks seems to have an effect on whether I can perform the third check. Am I missing something?
function f1(x: unknown): any {
return x && typeof x === 'object' && x.hasOwnProperty('x');
// ^ TS reports error: Object is possibly 'null'
}
function f2(x: unknown): any {
return typeof x === 'object' && x && x.hasOwnProperty('x'); // no error
}
Reproduced in 3.8-beta (playground link)