import { ActionContext } from 'vuex' ; import { Dictionary , PropsWithType } from '../utils' ; import { MutationsDictionary } from './mutations.types' ; import { AnyXStoreModule , ExtractPayload , RootXStoreState } from './store.types' ; /**
 * Type safe Vuex  https context, with the local
 * types of the module.
 *
 *  param State param Getters param Mutations param Actions public export interface XActionContext < State extends Dictionary , Getters extends Dictionary , Mutations extends MutationsDictionary < Mutations > , Actions extends ActionsDictionary < Actions > > extends ActionContext < State , RootXStoreState > { getters : Getters ; commit < MutationName extends PropsWithType < Mutations , ( ) => void > > ( mutation ) : void ; commit < MutationName extends keyof Mutations > ( mutation , payload ) : void ; dispatch < ActionName extends PropsWithType < Actions , ( ) => any > > ( action ) : ExtractActionReturn < Actions [ ActionName ] > ; dispatch < ActionName extends keyof Actions > ( action , payload ) : ExtractActionReturn < Actions [ ActionName ] > ; } param Action public export type ExtractActionReturn < Action extends ( payload ? : any ) => any > = ReturnType < Action > extends Promise < any > ? ReturnType < Action > : Promise < ReturnType < Action > > ; example public export type ActionsDictionary < Actions > = Record < keyof Actions , ( payload ? : any ) => any > ; /**
 * Type-safe actions definition type. An object with this type is what it is needed to define
 *  https actions.
 *
 *  param State param Getters param Mutations param Actions public export type ActionsTree < State extends Dictionary , Getters extends Dictionary , Mutations extends MutationsDictionary < Mutations > , Actions extends ActionsDictionary < Actions > > = { [ Key in keyof Actions ] : ( context : XActionContext < State , Getters , Mutations , Actions > , payload : ExtractPayload < Actions [ Key ] > ) => ReturnType < Actions [ Key ] > | Promise < ReturnType < Actions [ Key ] > > ; } ; public export type AnyActionsTree = ActionsTree < Dictionary , Dictionary , MutationsDictionary < any > , ActionsDictionary < any > > ; param Module public export type ActionsClass < Module extends AnyXStoreModule > = Partial < Module [ 'actions' ] > ;