-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed as not planned
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
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
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug