Improve typing for model type substitutability. #2189
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.