Preserve distinction between {}
and object
in compiled JSON
#13597
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 #13556
Given an object type declaration with no catchall schema, the type checker will issue warnings if a property whose name does not match any property declarations is supplied.
This means that given an object type declaration of
{}
, all supplied properties will trigger a BCP037 warning because an empty object was expected. This behaves differently from the untyped objectobject
, which matches without warning against any object. The distinction between{}
andobject
was getting dropped when templates were compiled to JSON, however, because the compiler wasn't including any information in the type definition that would allow the two to be distinguished; instead, they would both be compiled to{"type": "object"}
.This PR updates the compiler to include an empty
properties
constraint on object type declarations that include no properties so that it can tell the difference between{}
andobject
when loading or importing from JSON modules.Microsoft Reviewers: Open in CodeFlow