Created
November 22, 2023 16:16
-
-
Save tristan-f-r/fb5689632e11cea5fd2e31f46ad5a051 to your computer and use it in GitHub Desktop.
strict map and filter types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Array<T> { | |
map<U>( | |
callbackfn: (value: T, index: number, array: T[]) => U, | |
thisArg?: unknown | |
): { [K in keyof this]: U }; | |
filter<S extends T>( | |
callbackfn: (value: T, index: number, array: T[]) => value is S, | |
thisArg?: unknown | |
): { [K in keyof this]-?: this[K] extends S ? S : never } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment