Type alias TupleToUnion<T>

TupleToUnion<T>: T[number]

TupleToUnion<T> converts a tuple type T into a union type. This type is useful for scenarios where you need to work with the individual members of a tuple as a union.

Type Parameters

  • T extends readonly unknown[]

Example

type A = TupleToUnion<[1, 2, 3]>; // 1 | 2 | 3
type B = TupleToUnion<readonly ['a', 'b']>; // 'a' | 'b'
type C = TupleToUnion<[]>; // never