devtypes - v1.1.0
    Preparing search index...

    Type Alias UnionToTuple<U, T>

    UnionToTuple: [U] extends [never]
        ? T
        : UnionToTuple<Exclude<U, Last<U>>, [Last<U>, ...T]>

    Convert a union type to a tuple.

    Type Parameters

    • U

      Union type

    • T extends any[] = []

      Internal accumulator (used during recursion)

    Produces a tuple containing all members of the union. The resulting order is not guaranteed and should be treated as arbitrary.

    Performance degrades for large unions due to recursive conditional types.

    type U = 'a' | 'b' | 'c';
    type Tup = UnionToTuple< U >;
    // [ 'a', 'b', 'c' ] (order may vary)