Description
Version
3.0.1
Reproduction link
https://github.com/vuejs/vuex/blob/dev/types/vue.d.ts
Steps to reproduce
types/vue.d.ts
contains the following
declare module "vue/types/options" {
interface ComponentOptions<V extends Vue> {
store?: Store<any>;
}
}
declare module "vue/types/vue" {
interface Vue {
$store: Store<any>;
}
}
What is expected?
I feel like it should be possible to override this with store?: Store<MyState>
and $store: Store<MyState>
to allow this.$store
etc. on the Vue instance to be fully typed.
What is actually happening?
You can't redeclare an interface property, so trying to do so will result in a TypeScript error.
It feels like if you go to all the effort of fully typing out your whole vuex store it's rendered pretty much useless if your app makes heavy use of this.$store.state.foo
. This is especially an issue for me because I use nuxt and do a lot with $store
in the asyncData
functions. I've searched around for a fix or a workaround but not come up with much. Is there something I am missing here?