type-fest
type-fest copied to clipboard
`UnionToUnorderedTuple` type
I think it's worth adding this as long as we clearly document its downsides.
Initial attempt in https://github.com/sindresorhus/type-fest/pull/686
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- The funding will be given to active contributors.
- Thank you in advance for helping prioritize & fund our backlog.
We basically want to do what's described here, right? https://stackoverflow.com/a/55128956
Any other techniques?
Basically:
- Convert union values to return values of functions
-
UnionToIntersection
to make it an intersection - Intersection will be treated as a function overload from which the base return value (the last one in the original union) can be easily extracted
- Add that extracted last value to the the tuple result we want
- Repeat everything again with the remaining values that has not yet been extracted, adding one more item to the tuple for every iteration