fix: TSError2349 "This expression is not callable...." when calling action
jonnyparris opened this issue ยท 3 comments
๐ The bug
Typescript throws the following when calling an action This expression is not callable. Each member of the union type '(((options?: CommitOptions | undefined) => void) | ((payload: any, options?: CommitOptions | undefined) => void)) & (((options?: DispatchOptions | undefined) => void) | ((payload: any, options?: DispatchOptions | undefined) => void))' has signatures, but none of those signatures are compatible with each other.
However the function does work ๐คท๐พ .
๐ ๏ธ To reproduce
I have a submodule subbyMcModuleface
where doSomething
is defined as an action per the docs:
E.g. in "store/subbyMcModuleface/actions.ts"
import { actionTree } from 'typed-vuex'
import initialState from './state'
import getters from './getters'
import mutations from './mutations'
export default actionTree(
{ state: initialState, getters, mutations },
{
doSomething({ commit }, data) {
// do all the things
},
}
)
Then, in my component I to call store.subbyMcModuleface.doSomething()
but doSomething is highlighted with the aforementioned error.
Have I missed something? I'll have to reluctantly use // @ts-ignore
for that line as a workaround for now :(
๐ Expected behaviour
TS doesn't complain, Vetur lint continues to bless my code ๐๐พ
โน๏ธ Additional context
- In case it's relevant, I'm using
const store = useTypedStore()
where useTypedStore is imported fromconst useTypedStore = wrapProperty('$accessor', false)
. - Also it's a Nuxt project (^2.15.2)
@jonnyparris I love it - subbyMcModuleface will definitely make it into a future project. Any chance of a reproduction?
I created a minimal repro repo...which didn't have the problem so then I had a fun game of spot the difference only to realise that there was a duplicate method name collision between a mutation and the action I was trying to call within the same subbyMcModuleface! * sigh * ๐คฆ๐พ
Glad to get to the bottom of it without wasting too much of anyone's time.
Thanks for the super rapid reply and for your work on this package!
@jonnyparris Glad it's solved - and thanks for the kind words! โค๏ธ