Closed
Description
Bug Report
π Search Terms
type assertions order
π Version & Regression Information
Started at least from 3.3
β― Playground Link
Playground link with relevant code
π» Code
const receiver = (x: {}) => x;
const f = (x: unknown) => {
if (typeof x !== 'object' || x == null) {
return undefined
}
return receiver(x)
}
const f1 = (x: unknown) => {
if (x == null || typeof x !== 'object') {
return undefined
}
return receiver(x)
}
π Actual behavior
Has error: Argument of type 'object | null' is not assignable to parameter of type '{}'. Type 'null' is not assignable to type '{}'.
π Expected behavior
Shouldn't have any error. Checks are equivalent.
Metadata
Metadata
Assignees
Labels
No labels