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

Handle missing properties correctly #435

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

leilapearson
Copy link

Resolves #434

Changes the handling of missing properties in t.type interface 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.

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`
Copy link

@SHaTRO SHaTRO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

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.

Handle missing properties correctly
2 participants