-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue