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

Improve typing for model type substitutability. #2189

Merged

Conversation

thegedge
Copy link
Collaborator

@thegedge thegedge commented Jul 5, 2024

Previously, a model derived from an empty model couldn't be used in a place that asked for the empty model. In general, we had a lot of substitutability issues (just with our typing).

This commit fixes that by bringing back what was previously known as "$nonEmptyObject", but improves on it by not having it be as pervasive as it was previously (for example, it would show up on models that had props).

What does this PR do and why?

Fixes #2186

This PR fixes regressions introduced (by me! 😅) in the previous major release that attempted to remove $nonEmptyObject from all types. Little did we know, it did support stricter typing in some cases.

This PR reintroduces a similar concept, but it does so in a far more limited form to fix the aforementioned issue.

Steps to validate locally

The test is a good example, and validating would simply be running the type checker.

Previously, a model derived from an empty model couldn't be used in a place that
asked for the empty model. In general, we had a lot of substitutability issues
(just with our typing).

This commit fixes that by bringing back what was previously known as
"$nonEmptyObject", but improves on it by not having it be as pervasive as it was
previously (for example, it would show up on models that had props).
@coolsoftwaretyler
Copy link
Collaborator

Thanks, @thegedge! I'll take a look this weekend and merge/release a patch shortly.

@thegedge thegedge marked this pull request as ready for review July 6, 2024 15:43
@coolsoftwaretyler coolsoftwaretyler merged commit be7c425 into mobxjs:master Jul 7, 2024
1 check passed
@thegedge thegedge deleted the fix-derived-from-empty-typing branch July 8, 2024 13:35
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.

Broken model types in 6.0.0 version
2 participants