DEV Community

Discussion on: Vuex + TypeScript

Collapse
 
jay_2ae6ad576a843f profile image
Yunjie Jia

Hi, Harsh. I tried your method, but I still cannot use

store.dispatch('moduleName/actionName'), is there any fixes..

Collapse
 
harshgupta3 profile image
Harsh Gupta • Edited

Yes I solved, This is the solution you can refer

Solution for namespaced mutations

If you want a complete boilerplate with vue3 and other more configs you can clone or fork my repository.

github.com/techarshgupta/vue3-boil...

Thread Thread
 
jay_2ae6ad576a843f profile image
Yunjie Jia

Thank you!

I tried this method but seems like it will disable type check when I use

store.dispatch('moduleName/actionName') because I can pass any string and the compiler can compile successfully

type Namespaced = {

};
type NamespacedActions = Namespaced;

Thread Thread
 
harshgupta3 profile image
Harsh Gupta

no, it will give an error when you compile you can check my repo that I mentioned.