Skip to content

Instantly share code, notes, and snippets.

@haggen
Last active December 4, 2022 12:48
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 haggen/2184c58725aa2d7937b3cc5f8ae868de to your computer and use it in GitHub Desktop.
Save haggen/2184c58725aa2d7937b3cc5f8ae868de to your computer and use it in GitHub Desktop.
Extended TypeScript utility types.
/**
* Make all properties of T optional, except those in U. If exempt keys were already optional they'll stay optional.
*/
type Semipartial<T, U extends keyof T> = Partial<T> & Pick<T, U>;
/**
* Make all properties of T required, except those in U. If exempt keys were already required they'll stay required.
*/
type Semirequired<T, U extends keyof T> = Required<T> & Pick<T, U>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment