There are cases where you need Store<StateType> directly.
And there's no way to write it.
When we use vuex-simple we write classes instead of a regular Store, and we do not have this StateType, since it is bundled with other methods, getters, etc.
What do I suggest?
import { State, Module, StateTypeOf } from 'vuex-simple'
class CommentsModule {
@State()
public comments: CommentType[] = []
}
class TypedStore {
@Module()
public comments = new CommentsModule()
}
type StateType = StateTypeOf<typeof TypedStore>
And later it can be used for Store<StateType>. This way we have the best from the bosth worlds. Native types and no code duplication.
Similar approach: https://github.com/gcanti/io-ts#typescript-integration
I'm submitting a ...
[ ] bug report
[x] feature request
[x] question about the decisions made in the repository
[x] question about how to use this project
Summary
There are cases where you need
Store<StateType>directly.And there's no way to write it.
When we use
vuex-simplewe write classes instead of a regularStore, and we do not have thisStateType, since it is bundled with other methods, getters, etc.What do I suggest?
And later it can be used for
Store<StateType>. This way we have the best from the bosth worlds. Native types and no code duplication.Similar approach: https://github.com/gcanti/io-ts#typescript-integration