I got vujes typescript project and in vuex store i got something like:
async getUserProfile ({ dispatch, commit }: any) {}
Well i dont want any
because that suck and you dont have help/autocomplete in editor. I found this import { Dispatch, Commit } from "vuex";
but how to pass that info to { dispatch, commit }: any
You use ActionContext<S, R>
, like Vuex does:
getUserProfile( context: ActionContext<S, R>) {}
Where S
is the State
and R
is the RootState
.
Then you call dispatch
and commit
off of the context:
context.dispatch('action')
context.commit('mutation')