Proof of concept for usage of [template literal types] for vuex stores and modules. For now it supports nested (namespaced and not) modules and checking mutation (name, payload)
pairs but for now allows only argument style commit function.
- Modules
- Global
VuexGlobalModule<TState, TMutations = {}, TActions = {}, TModules = {}, TGetters = {}>
- Namespaced
VuexNamespacedModule<TState, TMutations = {}, TActions = {}, TModules = {}, TGetters = {}>
- State
TState
- State helper
VuexState<TModule>
- Own
VuexOwnState<TModule>
- From submodules
- Own
- State helper
- Mutations
TMutations extends VuexMutationsTree
- Non-type-safe fallback
VuexMutationsTree
?? - Available mutations
VuexMutations<TModule>
- Own
VuexOwnMutations<TModule>
- From submodules
- Global
- Namespaced
- Own
- Mutation handler type
VuexMutationHandler<TState, TPayload = never>
- Properly type
this
in handler (store backref)
- Properly type
- Commit types
-
PayloadType is too deepVuexMutationPayload<TModule, TMutation>
- Argument-Style
VuexCommit<TModule>
- Object-Style
VuexMutations<TModule>
- Commit options
VuexCommitOptions
- Support
{ root: true }
- Support
-
- Non-type-safe fallback
- Actions
TActions extends VuexActionsTree
- Non-type-safe fallback
VuexActionsTree
?? - Available actions
VuexActions<TModule>
- Own
VuexOwnActions<TModule>
- From submodules
- Global
- Namespaced
- Own
- Action handler
VuexActionHandler<TState, TPayload = never, TResult = Promise<void>>
- Action Context
VuexActionContext<TModule, TStoreDefinition = any>
- Properly type
this
in handler (store backref)
- Action Context
- Dispatch type
VuexDispatch<TModule>
- Payload
VuexActionPayload<TModule, TAction>
- Result
VuexActionResult<TModule, TAction>
- Argument-Style
- Object-Style
VuexAction<TModule>
- Dispatch Options
VuexDispatchOptions
- Support
{ root: true }
- Support
- Payload
- Non-type-safe fallback
- Getters
TGetters extends VuexGettersTree
- Non-type-safe fallback
VuexGettersTree
?? - Available getters
VuexGetters<TModule>
- Own
VuexOwnGetters<TModule>
- From submodules
- Global
- Namespaced
- Own
- Getter type
VuexGetter<TState, TResult>
- Result
VuexGetterResult<TModule, TGetter>
- Non-type-safe fallback
- Submodules
TModules extends VuexModulesTree
- Global
- Store Definition
VuexStoreDefinition<TState, TMutations = {}, TActions = {}, TModules = {}, TGetters = {}, TPlugins = {}>
- Basically
VuexGlobalModule
with additional things - Plugins
VuexPlugin<TStoreDefinition>
- Simple properties (
devtools
, etc.)
- Basically
- Store instance
VuexStore<TStoreDefinition>
- Constructor
- Store Options
VuexStoreOptions<TDefinition>
- Store Options
- State (as defined by TStoreDefinition)
- Replace state
replaceState
- Replace state
- Getters (as defined by TStoreDefinition)
- Commit (as defined by TStoreDefinition)
- Dispatch (as defined by TStoreDefinition)
- Subscribers
- Options
SubscribeOptions
- Actions
subscribeAction
- Subscriber
VuexActionSubscriber<TDefinition>
- Hook
VuexActionHook<?>
- Error
VuexActionError<?>
- Object
VuexActionSubscribersObject<TDefinition>
- Hook
- Subscriber
- Mutations
subscribe
- Subscriber
VuexMutationSubscriber<TDefinition>
- Subscriber
- Options
- Watch
watch
- Options
WatchOptions
- Options
- Dynamic module management
- Registration
registerModule
- Unregistration
unregisterModule
- Presence check
hasModule
- Registration
- Hot Update ??
- Constructor
click [template literal types]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#template-literal-types