Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide overload for type predicates #19

Open
5 tasks done
scarf005 opened this issue Dec 17, 2023 · 0 comments · May be fixed by #20
Open
5 tasks done

provide overload for type predicates #19

scarf005 opened this issue Dec 17, 2023 · 0 comments · May be fixed by #20
Assignees

Comments

@scarf005
Copy link
Collaborator

scarf005 commented Dec 17, 2023

interface Array<T> {
    /**
     * Returns the value of the first element in the array where predicate is true, and undefined
     * otherwise.
     * @param predicate find calls predicate once for each element of the array, in ascending
     * order, until it finds one where predicate returns true. If such an element is found, find
     * immediately returns that element value. Otherwise, find returns undefined.
     * @param thisArg If provided, it will be used as the this value for each invocation of
     * predicate. If it is not provided, undefined is used instead.
     */
    find<S extends T>(predicate: (value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined
    find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined
}

(code from https://github.com/microsoft/TypeScript/blob/4d5ba0316a43ea31c41c50e4d62756659ddffbaa/src/lib/es2015.core.d.ts#L1-L12)

functions like find and filter should be able to utilize type predicates.

Todo

Overloads

  • find
  • filter
  • every
  • takeWhile
  • dropWhile

handle curryIterFunction

related:

@scarf005 scarf005 self-assigned this Dec 17, 2023
@scarf005 scarf005 linked a pull request Dec 17, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant