I have this basic model.
const stuff = types.model({
term: types.string,
excludeTerm: types.string,
stores: types.array(types.string)
}).actions(self => ({
setTerm(term: string) {
self.term = term
},
setExcludeTerm(term: string) {
self.excludeTerm = term
},
setStores(stores: string[]) {
self.stores = stores // <<< the lint error is on this line
}
}))
I get the following TS Lint error:
Type 'string[]' is not assignable to type 'IMSTArray<ISimpleType> & IStateTreeNode<IArrayType<ISimpleType>>'. Type 'string[]' is missing the following properties from type 'IMSTArray<ISimpleType>': spliceWithArray, observe, intercept, clear, and 4 more.ts(2322)
This is an annoying error. I can fix it by assigning like this: (self as any).stores = stores
but I want to stop doing hacks to my code.
The question is why I get this error? Is there another way to assign to an array type in mobx-state-tree?
I couldn't find in mobx-state-tree a more detailed documenation for working with arrays. Does anyone know any?