I'm currently facing an issue while working with Vuex and TypeScript. I have encountered the following error in my code, but I am unsure how to resolve it: The error :
TS2322: Type '(state: State, exRep: number, exName: string) => void' is not assignable to type 'Mutation '
Here is a snippet of my code :
import { createStore } from "vuex";
import {State} from "./Types";
const store = createStore<State>({
state() {
return {
exercices: []
}
},
mutations: {
addEx(state: State, exRep: number, exName: string) {
const exId = checkid()
state.exercices.push({ "rep": exRep, "name": exName, "id": exId })
},
removeEx(state: State, exoId: Number) {
console.log(exoId)
state.exercices = state.exercices.filter(obj => obj.id !== exoId)
}
}
})
export default store
The error specifically occurs at the "addEx" mutation.