I want to use modules for a vuex (^4.0.2) store that should work with typescript. So I just started to out like that:
import {createStore, Module} from 'vuex';
type RootState = {
appID: string
}
type SessionState = {
lastSeen: number
}
const session: Module<SessionState, RootState> = {
state: () => ({ lastSeen: -Infinity })
}
const store = createStore<RootState>({
state: () => ({appID: 'r2d2'}),
modules: {
session
}
});
const s2 = store.state.session;
But that yields this error:
Property 'session' does not exist on type 'RootState'.
The docs suggest that the state of each module is included within the state of the store and using this:
//@ts-ignore
console.log(store.state.session)
show that the module is included.
How should types be setup to properly reflect the state?