Handle missing properties correctly#435
Open
leilapearson wants to merge 8 commits intogcanti:masterfrom
Open
Conversation
A property can only be missing if the property is optional. Properties with types that accept undefined values must always be present unless they are optional properties.
Also remove some `type` tests that are redundant since the following are equivalent: - `null` and `nullType` - `void` and `voidType` - `strict` and `exact`
SHaTRO
reviewed
Sep 25, 2021
SHaTRO
left a comment
There was a problem hiding this comment.
Declaring something as "undefined" is semantically equivalent to declaring it as missing.
One should use "null" to declare a property as "exists (can exist) but with no value".
This PR does not appear to respect those semantics and therefore is definitively a breaking change and inconsistent with the semantic definition of "undefined".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #434
Changes the handling of missing properties in
t.typeinterface types to align with TypeScript.Adds many additional tests (~170) to confirm that everything behaves as expected. Also changes a small number of pre-existing tests that asserted the old behavior.
Note that people who rely on the old behavior may see this fix as a breaking change.