Skip to content

Instantly share code, notes, and snippets.

@streamich
Last active November 25, 2018 18:50
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 streamich/332080c117d06c859769cf5f33610680 to your computer and use it in GitHub Desktop.
Save streamich/332080c117d06c859769cf5f33610680 to your computer and use it in GitHub Desktop.

Specify required fields, rest will be optional.

export type Required<T, K extends keyof T> = Partial<T> & Pick<T, K>;

Specify which fields to omit.

export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

Branded types.

export type Branded<Base, Type> = Base & {__brand__: Type};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment