'How transfer multi parametrs to vuex mutation with respect TypeScript

I'm trying to lunch a mutation but my param is udefine how should I properly transfer my varrables to make this function works? Pleace help

Component

    props:{
      detailGoalIdex:{
        type: Number
      }
    },
    setup(detailGoalIdex) {
    const store = useStore()

    let taskTemplate = {
      title:'',
      description:'',
      quote:'',
    }

    function addTask(){
      store.commit( 'ADD_TASK', {taskTemplate, detailGoalIdex} )
    }//jj. on btn 
}

Store

ADD_TASK(store, {task, detailGoalIdex}:{task:task, detailGoalIdex:number} ){

  if(store.documents){
     console.log('detailGoalIdex',detailGoalIdex )
     console.log('task',task) //jj. undefine   
//store.documents[0].document.content.mainGoal.detailGoals[detailGoalIdex].tasks.push(task) //jj.this is to achieve
  }
},


Solution 1:[1]

Where you commit you set a taskTemplate property for the payload. However in the mutation you wait for a task property. Yo can try

store.commit( 'ADD_TASK', { task: taskTemplate, detailGoalIdex} )

instead of

store.commit( 'ADD_TASK', {taskTemplate, detailGoalIdex} )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zoltán Dobrovolni