Skip to content

Instantly share code, notes, and snippets.

@babakness
Last active August 6, 2018 16:00
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 babakness/0031c9457737f20559e4894a52ea9869 to your computer and use it in GitHub Desktop.
Save babakness/0031c9457737f20559e4894a52ea9869 to your computer and use it in GitHub Desktop.
Simple Flatten Type
type Flatten<T> = T extends any[] ? T[number] : T;
// If you want to flatten no lower than one level
type FlattenArray<T> = T extends any[][] ? T[number] : T;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment