here is how you do it
type TupleToArray<
T extends unknown[],
Acc = never
> = T extends [infer H, ...infer Rest]
? Rest extends []
? (H | Acc)[]
: TupleToArray<Rest, Acc | H>
: "impossible route"
type A = TupleToArray<[number, string, boolean]> // (string | number | boolean)[]
joke, I was messing, here is the easy way
type B = [number, string, boolean][number][] // (string | number | boolean)[]
Top comments (0)