Closed sparten11740 closed 7 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
f28dd6f
) 99.54% compared to head (92bba82
) 99.54%.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
This PR relaxes the type on object properties to accommodate for conflicting type inference as reported in #170
A simplified version of the issue we are facing is the following:
Is inferred as
properties
amongst other is typed as{ [id: string]: Schema }
. This index signature states that if we have a property, it has to be of typeSchema
and cannot beundefined
. This conflicts with the type that is inferred from e.g. an array provided toallOf
, where one element references a different property than the other. Similar to the example above one property in one branch of the union type will then be inferred aspropA?: undefined
.A possible solution is to allow keys with
undefined
values in the index signature using eitherPartial<{ [id: string]: Schema }>
or<{ [id: string]: Schema | undefined }>
. The caveat of is that obviously a key with anundefined
value does not make sense inproperties
. Worth paying that price?This PR does that and adds a test case for the bug from #170
Closes #170