I have a Foo
type that consists of multiple types
For example:
type Foo = string | number
I need to receive this type and convert it into an array of the individual types within the union
type TransformedFoo = ToUnionOfArray<Foo> // => string[] | number[]
Simply using Foo[]
won't work in this case, since it would result in (string | number)[]
.
What's the best way to turn a union type into an array of its constituent types?