I have an array of the form
const arr = [
{ foo: 'a' },
{ foo: 'b' },
...
] as const;
One thing this lets me do is generate the union type 'a' | 'b' | ...
with typeof arr[number]['foo']
. However, if I want to get the array form of the union type (like String Union to string Array), there doesn't seem to be a good solution.
arr.map(({foo}) => foo)
is of type ('a' | 'b' | ...)[]
instead of readonly ['a', 'b', ...]
. How can I get the latter?