Closed SaphuA closed 4 years ago
Seems like the tests in create-proxy.spec.ts
are already failing because of this.
Is this currently not true for ANY namespaced module (root or submodule)? I'm seeing this exact issue on latest, on namespaced modules (not submodules). It appears the mutation is named globally, but called locally (using module commit, rather than store.$commit)
I've run into this issue, and have a workaround:
Name your namespaced submodule field to be the same as the class: subN -> SubStoreN
this fixes your repro
My further issue is if an action on a store is mutating state on that store, I get a similar error.
My workaround is to change:
if (commit)
commit(utils_1.refineNamespacedPath(cls.prototype.__namespacedPath__) + ("__" + className + "_internal_mutator__"), { field: path, payload: payload });
to
if (commit)
commit(utils_1.refineNamespacedPath(cls.prototype.__namespacedPath__) + ("__" + className + "_internal_mutator__"), { field: path, payload: payload }, {root: true);
in Proxy.js I'm not sure this is "the right way" to do this, it just got me past this issue, for now
HTH
[Edited to update dependency to latest fixes] I have a PR for this fix up. In the meantime, I've been using my fork of the lib, by targeting a built commit, as such:
// package.lock dependencies
...
"vuex-class-component": "git+https://github.com/tiagoroldao/vuex-class-component.git#f71e27bc4960607081a936c3a756915656af520b",
...
I have had great sucess with an alternative library which is still maintained, perhaps it is of interest to people https://github.com/paleo/direct-vuex
Cheers @SaphuA 😄
It seems like there's an issue when a namespace is applied to submodules. Those without namespaces work, but naming collisions are quite annoying so I'd rather have namespaces. It seems that the module is correctly registered with a namespace, but the internals are probably not taking the namespaces into account.
I've updated my previous repo: https://github.com/SaphuA/vuex-class-component-ns-repro The error is in store.ts: https://github.com/SaphuA/vuex-class-component-ns-repro/blob/master/src/store.ts#L42
Sorry to bring you only bad news all the time ;)