Skip to content

Instantly share code, notes, and snippets.

@timvandam
Created January 13, 2024 15:37
Show Gist options
  • Save timvandam/d45827dd01c8684d53771647c7783bfb to your computer and use it in GitHub Desktop.
Save timvandam/d45827dd01c8684d53771647c7783bfb to your computer and use it in GitHub Desktop.
TypeScript union permutations
type Permutations<T, O = T> = [T] extends [never] ? [] : T extends any ? [T, ...Permutations<Exclude<O, T>>] : never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment