Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 635 Bytes

types-kit.uniontotuple.md

File metadata and controls

25 lines (16 loc) · 635 Bytes

Home > types-kit > UnionToTuple

UnionToTuple type

Convert union type to a tuple.

Signature:

export type UnionToTuple<U> = [U] extends [never] // no type
  ? []
  : [...UnionToTuple<Exclude<U, LastInUnion<U>>>, LastInUnion<U>]

References: UnionToTuple, LastInUnion

Example

// Expect: ['3', '1', '2']
type Foo = UnionToTuple<'3' | '1' | '2'>