The helper which makes vuex more type-safety

vuex-typescript-fsa

The helper function for inferring a combination of action/mutation and handler.

Installation

npm install vuex-typescript-fsa

Usage

const Increment = actionCreator<number>("Increment");

const store = new Store<{ count: number }>({
  state: {
    count: 0
  },
  actions: combineAction(
    action(Increment, function(context, action) {
      context.commit(action);
    })
  ),
  mutations: combineMutation(
    mutation(Increment, function(state, action) {
      state.count = action.payload;
    })
  )
});

store.dispatch(Increment(10));

GitHub