Accessing a field of a model that inherits from another leads to a missing type error #1833
Open
3 tasks done
Labels
help/PR welcome
Help/Pull request from contributors to fix the issue is welcome
Typescript
Issue related to Typescript typings
Bug report
Sandbox link or minimal reproduction code
The error can be seen in particular at the above code sandbox in the
Person.ts
file.Describe the expected behavior
When using
getRoot
to access a model that is composed over a variety of others e.g. a model of typeFood
whereand
Orange
andApple
are created viaFruit.props({...})
, I'd expect that properties that only exist on one of the "child" models would be optional i.e. would return asundefined
if the runtime model was one without that field. In the sandbox linked to for example I would expect to be able to calland for
seeded
to beundefined
for anApple
and a boolean for anOrange
.Describe the observed behavior
Only the properties from the "Parent" model (in this case the
Fruit
model) are recognised as valid properties by Typescript.For example, in the code sandbox example when trying to access the
seeded
property there is a compilation error thatseeded
does not exist on the type.Looking at the error it seems to be using an intersection of properties rather than a union.
The text was updated successfully, but these errors were encountered: