Vue-class-component: How to annotate Vuex store type?

Created on 7 May 2017  路  4Comments  路  Source: vuejs/vue-class-component

How can I annotate my component to declare the type of my Store, such that my component doesn't give this.$store the type Vue.$store: Store<any>?

Most helpful comment

https://github.com/vuejs/vuex/blob/dev/types/vue.d.ts lists $store as Store<any> and the question was how to annotate it to be Store<MyState>.

All 4 comments

If you import vuex it is automatically declared in Vue constructor.
https://github.com/vuejs/vuex/blob/dev/types/vue.d.ts

https://github.com/vuejs/vuex/blob/dev/types/vue.d.ts lists $store as Store<any> and the question was how to annotate it to be Store<MyState>.

Anyone found a solution for this?
It would be great to fully type the store and then have auto-completion for this.$store (e.g. for this.$store.getters). Currently this.$store.getters has type any, which is not ideal.

solution is still needed...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KokoDoko picture KokoDoko  路  6Comments

viT-1 picture viT-1  路  4Comments

kabaluyot picture kabaluyot  路  3Comments

hesi726 picture hesi726  路  5Comments

nqthiep picture nqthiep  路  6Comments