Closed blackmad closed 5 years ago
I would remove the dependency for vuex and just use vuex-typescript-interface. The vuex types interfere. This library supplies the vuex functionality but with better type support.
While your workaround works for projects where vuex has been installed directly as a dependency, it does not work for e. g. nuxt.js which depends on vuex itself.
Is there anything we can do until microsoft/TypeScript#18588 has landed 🙁?
@mrkswrnr The workaround last time I had this problem was to cast your store to unknown
then cast it to the Vuex
store. Something like this:
import { mystore } from './mystore';
import { Store } from 'vuex';
new Vue({
store: mystore as unknown as Store
});
Thanks for your response!
The problem with Nuxt is that stores are not created directly but by convention. Every .js/.ts file inside the store directory is transformed as a namespaced module (index being the root module) (see: Vuex Store - Nuxt.js).
Therefore there is no real store initialisation written by the user. Your definition of vue.d.ts collides with Vuex's vue.d.ts which is required by Nuxt.js.
My only workaround for the moment was to fork your project and exclude the vue.d.ts, loosing the possibility to use the type store easily.
No idea why I'm getting this error from deep inside the library
my store.ts looks like this