Skip to content

[Request] Enhance find() method typing with predicate-based return type #24

@montoriusz

Description

@montoriusz

Is your feature request related to a problem? Please describe.
The following signature is missing from Iterator interfaces typings:

find<R extends T>(fn: (value: T, index: number) => value is R): R | undefined;

Describe the solution you'd like
Add the given snippet to Iterator interfaces.

Describe alternatives you've considered
Augmenting interfaces via declaration merging does not cause TypeScript to pick up the predicate-based signature that is added. The signature must be put before the default one.

Additional context
Library typing for Array.prototype.find() is predicate-based.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions