import { ActionTree , MutationTree , GetterTree , ActionContext } from 'vuex' ; import { RootState } from './index' ; export interface State { count : number ; } export const types = { INCREMENT : 'INCREMENT' , DECREMENT : 'DECREMENT' } ; export const state = ( ) : State => ( { count : 0 } ) ; export const getters = { currentCounter : state => ( ) => { return { count : state . count } ; } } ; export interface Actions < S , R > extends ActionTree < S , R > { increment ( context ) : void ; decrement ( context ) : void ; } export const actions = { increment : ( { commit } ) => { commit ( types . INCREMENT ) ; } , decrement : ( { commit } ) => { commit ( types . DECREMENT ) ; } } ; export const mutations = { [ types . INCREMENT ] : ( state ) : void => { state . count ++ ; } , [ types . DECREMENT ] : ( state ) : void => { state . count -- ; } } ;