Closed
Description
π Search Terms
optional, inference, callback
π Version & Regression Information
- Behaviour changed between versions 5.0 and 5.1
β― Playground Link
π» Code
export function filter<T>(predicate: (value: T, index: number) => boolean): T {}
const a = filter((pose?: number) => true);
π Actual behavior
a
gets inferred as number
π Expected behavior
a
gets inferred as number|undefined
(this is the case in 5.0.4)
I'm not certain if this change is caused by a bug or intentional, but I couldn't find anything from the announcement at least that made this change, so rather asking for clarification on whether this is an intended behavior
Additional information about the issue
The original definition of filter
comes from rxjs (simplified in the example for reporting purpose) : https://github.com/ReactiveX/rxjs/blob/2947583bb33e97f3db9e6d9f6cea70c62a173060/src/internal/operators/filter.ts#L6