Closed as not planned
Description
π Search Terms
filter type predicate
π Version & Regression Information
This only makes sense since TS5.5, when inferred type predicates were introduced.
β― Playground Link
π» Code
const a = ['test', null]
const b = a.filter(x => x !== null)
const c = a.filter(x => x !== null && x.startsWith('t'))
π Actual behavior
On the above, the type of b
is correctly inferred as string[]
, but the type of c
is incorrectly inferred to (string | null)[]
π Expected behavior
The inferred type of c
should string[]
, just like the inferred type of b
.
Additional information about the issue
No response