Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnionToUnorderedTuple type #819

Open
sindresorhus opened this issue Feb 22, 2024 · 2 comments
Open

UnionToUnorderedTuple type #819

sindresorhus opened this issue Feb 22, 2024 · 2 comments
Labels
help wanted Extra attention is needed type addition

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Feb 22, 2024

I think it's worth adding this as long as we clearly document its downsides.

Initial attempt in #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.
Fund with Polar
@voxpelli
Copy link
Collaborator

We basically want to do what's described here, right? https://stackoverflow.com/a/55128956

Any other techniques?

@voxpelli
Copy link
Collaborator

voxpelli commented Feb 22, 2024

Basically:

  1. Convert union values to return values of functions
  2. UnionToIntersection to make it an intersection
  3. 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
  4. Add that extracted last value to the the tuple result we want
  5. Repeat everything again with the remaining values that has not yet been extracted, adding one more item to the tuple for every iteration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type addition
Projects
None yet
Development

No branches or pull requests

2 participants