Skip to content

Instantly share code, notes, and snippets.

@LeoDog896
Created November 22, 2023 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeoDog896/fb5689632e11cea5fd2e31f46ad5a051 to your computer and use it in GitHub Desktop.
Save LeoDog896/fb5689632e11cea5fd2e31f46ad5a051 to your computer and use it in GitHub Desktop.
strict map and filter types
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