-
Notifications
You must be signed in to change notification settings - Fork 13k
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
π 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
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