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

Cast #236

Merged
merged 5 commits into from
Sep 8, 2022
Merged

Cast #236

merged 5 commits into from
Sep 8, 2022

Conversation

sinclairzx81
Copy link
Owner

This PR implements a more sophisticated scoring scheme for union resolution during casting. The updated algorithm now factors proportional property scoring, property existence checks and biasing for matching literal const values.

This PR also includes a new Type.Never() type which was introduced in this PR to express empty unions, as these were catching on casting logic. This type is also to serve as new type infrastructure for planned future work on Type.Intersect() and a new Type.Evaluate() function which will need to evaluate to never for certain kinds of type composition.

const T1 = Type.Union([])              // T1 = TNever

const T2 = Type.Union([Type.String()]) // T2 = TUnion<[TString]>

@sinclairzx81 sinclairzx81 merged commit 9cbc504 into master Sep 8, 2022
@sinclairzx81 sinclairzx81 deleted the cast branch September 8, 2022 23:03
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

1 participant