I have a bunch of stores each containing a list of one entity type like
const userStore = EntityStore.create(....)
const supplierStore = EntityStore.create(....)
Some stores can offer additional functionalities, so I wrote
const orderStore = EntityStore
.views(self => ({
allByUserId: branchId => ....)
}))
.create(....)
So far, everything was fine, but now I wanted to create a "store manager" containing a list of all such stores and it failed with a message like
Error: [mobx-state-tree] Error while converting ...
value of type EntityStore: (id: Order)> is not assignable to type:EntityStore
,
expected an instance ofEntityStore
or a snapshot like ... instead
(Note that a snapshot of the provided value is compatible with the targeted type)
The message is clear, my "EntityStore with views" is not of the same type as an "EntityStore". But it's an extension of it, so I wonder if there's a declaration allowing it. Something like List<? extends EntityStore>
in Java?
Or a nice workaround allowing me to add the additional functionality to EntityStore
without changing its type?