Making union out of tuple
Today we discuss Tuple to Union
We already solved a similar challenge Making object out of tuple.
This one is useful when we need to extract elements type out of tuple.
Iteration over a tuple
As we discussed it in Making object out of tuple and Includes, we can use Indexed Access Types to get the type of tuple's elements:
Here we use
extends any as Generic Constrain to be able to call
T[number] without errors
All together in Playground with test cases
Have a wonderful day ☀️typescript