Skip to content

Fix intersections #129

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

Merged
merged 4 commits into from
Apr 30, 2020
Merged

Fix intersections #129

merged 4 commits into from
Apr 30, 2020

Conversation

andnp
Copy link
Owner

@andnp andnp commented Apr 26, 2020

In typescript 3.9.0, the intersection between two objects will be
never if the two objects have incompatible private members. This broke
an implicit behavior that CombineObjects was taking advantage of;
element-wise intersection. Because CombineObjects is intended to be a
thin wrapper over the raw intersection type, I don't want its contract
to deviate from the intersection. So instead I added the
ElementwiseIntersect utility; which relies on the newly added TryKey
utility.

TryKey is just like GetKey, except it fails "silently" when the key
does not exist. Specifically, GetKey returns never so that the
resultant type is unusable and TryKey returns unknown which can be
eliminated via intersection.

Relevant PR from typescript which changed behavior of intersections (and
broke the future-proofing test cases):
microsoft/TypeScript#37762

andnp added 3 commits April 26, 2020 06:21
In typescript 3.9.0, the intersection between two objects will be
`never` if the two objects have incompatible private members. This broke
an implicit behavior that `CombineObjects` was taking advantage of;
element-wise intersection. Because `CombineObjects` is intended to be a
thin wrapper over the raw intersection type, I don't want its contract
to deviate from the intersection. So instead I added the
`ElementwiseIntersect` utility; which relies on the newly added `TryKey`
utility.

`TryKey` is just like `GetKey`, except it fails "silently" when the key
does not exist. Specifically, `GetKey` returns `never` so that the
resultant type is unusable and `TryKey` returns `unknown` which can be
eliminated via intersection.

Relevant PR from typescript which changed behavior of intersections (and
broke the future-proofing test cases):
microsoft/TypeScript#37762
@andnp andnp requested a review from Retsam as a code owner April 26, 2020 15:32
@andnp andnp merged commit 3ebb063 into master Apr 30, 2020
@andnp andnp deleted the Fix-Intersections branch April 30, 2020 17:00
@andnp
Copy link
Owner Author

andnp commented Apr 30, 2020

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@andnp andnp added the released label Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant