Skip to content

Instantly share code, notes, and snippets.

@AyAyEm
Last active November 3, 2020 12:36
Show Gist options
  • Save AyAyEm/a99e7def3157e62656ae0cbb37515ceb to your computer and use it in GitHub Desktop.
Save AyAyEm/a99e7def3157e62656ae0cbb37515ceb to your computer and use it in GitHub Desktop.
All sort of generics used to extract types from types
// Map
type MapExtract<MapType> = MapType extends Map<infer X, infer Y> ? [X, Y] : never;
// All types of objects
type ObjectExtract<ObjectType> = [keyof ObjectType, ObjectType[keyof ObjectType]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment