Skip to content

Instantly share code, notes, and snippets.

@garenyondem
Created December 28, 2021 19:49
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 garenyondem/62a0c89c66a8fd6d80ff6cea504a1eab to your computer and use it in GitHub Desktop.
Save garenyondem/62a0c89c66a8fd6d80ff6cea504a1eab to your computer and use it in GitHub Desktop.
Typescript Flatten two types
type Flatten<T> = T extends object ? {
[P in keyof T]: Flatten<T[P]>
} : T;
type A = { foo: boolean } & { bar: string };
type B = Flatten<A>; // { foo: boolean; bar: string; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment