UnionToTuple<T> converts a union type T into a tuple type. This type is useful for scenarios where you need to work with the individual members of a union as an ordered list.
UnionToTuple<T>
T
The union type to convert into a tuple.
The last member of the union, used for recursive extraction.
A boolean that checks if the union is empty.
type TestUnion = 'a' | 'b' | 'c';type ResultTuple = UnionToTuple<TestUnion>; // Result: ['a', 'b', 'c'] Copy
type TestUnion = 'a' | 'b' | 'c';type ResultTuple = UnionToTuple<TestUnion>; // Result: ['a', 'b', 'c']
UnionToTuple<T>
converts a union typeT
into a tuple type. This type is useful for scenarios where you need to work with the individual members of a union as an ordered list.