Skip to content

Instantly share code, notes, and snippets.

@babakness
Last active August 6, 2018 16:00
Show Gist options
  • 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