vuex-typex: I get the following error: Vuex handler functions must not be anonymous

Hi all

I have a Store module like this:

import { IRobotState } from '@types'
import {storeBuilder} from "./StoreBuilder"
import axios from 'axios'

//State
const state: IRobotState = {
    serieID : "",
    productionCount: 0,
    rapidValue: 0
}

const RobotStateMod = storeBuilder.module<IRobotState>("RobotModule", state);
const stateGetter = RobotStateMod.state();

namespace Getters {

    export const getters = {
        get getRobotSerieID() { return state.serieID },
        get getProductionCount() { return state.productionCount; }
    }
}

namespace Mutations {
    function setRobotSerieID(state:IRobotState, robotSerieId: String)
    {
        state.serieID = robotSerieId;
    }

    export const mutations = {
        commitSetRobotSerieID: RobotStateMod.commit(setRobotSerieID)
    }
}

namespace Actions {

     async function getRobotSerieID()
    {

    }

    export const actions = {
        dispatchGetRobotSerieID: RobotStateMod.dispatch(getRobotSerieID)
    }
}

// Module
const RobotStateModule = {
    get state() { return stateGetter()},
    getters: Getters.getters,
    mutations: Mutations.mutations,
    actions: Actions.actions
  }
  
  
  export default RobotStateModule;

but it gives the following error when I try to load the page after production build - in dev build it works fine:

Uncaught Error: Vuex handler functions must not be anonymous. Possible causes: fat-arrow functions, uglify. To fix, pass a unique name as a second parameter after your callback.

In the stack trace it marks javascript commitSetRobotSerieID: RobotStateMod.commit(setRobotSerieID) as the one of the possible causes…

Is there someone who has an idea?

@victorgarciaesgi I have tried to follow your Moving-Mate example - so maybe you have experienced it?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (1 by maintainers)

Most upvoted comments