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

Implements WidenLiteral in terms of Join helper #145

Closed

Conversation

ahrjarrett
Copy link

Happy to add additional tests or make adjustments. Also I'm not sure if I should inline Join, will that leak into the global namespace the way I declared it?

This alternate definition of WidenLiteral should be at parity with the current implementation. It works by distributing both types (the lower bound, and the upper bound), and choosing the upper member in the event of an intersection.

I named it join because that feels like the correct term, but I don't have a math background so I could be wrong.

@mattpocock
Copy link
Collaborator

Oddly I prefer the more explicit one, since it's dead-simple to understand.

@mattpocock mattpocock closed this May 29, 2023
@ahrjarrett ahrjarrett deleted the ahrjarrett@join-prim branch May 30, 2023 12:31
@ahrjarrett
Copy link
Author

IMO WidenLiteral is not dead-simple at all. In fact, I'd say it takes a pretty advanced understanding of how unions work in TS to appreciate the amount of implicit work it's doing.

I respect your right to close this PR, and won't press the issue. This quote comes to mind, it's one of my favorites, so I'll share it:

The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise.

Best of luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants