Skip to content

Instantly share code, notes, and snippets.

@FFKL
Created March 6, 2020 20:18
Show Gist options
  • Save FFKL/5820dea6b54581699ccce9404d5f9b28 to your computer and use it in GitHub Desktop.
Save FFKL/5820dea6b54581699ccce9404d5f9b28 to your computer and use it in GitHub Desktop.
This type is used to select the field names of the type (T) by the specified type (P).
type OnlyPickedTypeFields<T extends object, P> = { [K in keyof T]: T[K] extends P ? K : never }[keyof T];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment