The basic procedure is as follows: You create an interface RootState
that
defines your fields. You probably already have types for these various data
items. You may have been previously forced to cast your bottom values to avoid
ending up as never[]
, etc. So create an interface representing these values.
Then refactor your store to type-check correctly when the object is assigned
to a variable fo type StoreOptions<RootState>
.
Then you derive another type as such.
import { Module } from 'vuex';
// ...
const graphView: Module<GraphViewState, RootState> = {
// ...
}
Move all the previous contents of RootState
into GraphViewState
(in this
example). RootState
itself should become an empty interface.
Now you can include this in the modules
key when constructing your Vuex store.
const store: StoreOptions<RootState> = {
modules: { graphView }
};
export default new Vuex.Store(store);