I just read a blog post which explained that TypeScript 2.1 has a new feature which makes it possible to type-check the keys of objects. Here's the blog post.
So basically I'm imagining that it should also be possible to do this with vuex, since the store object is just a regular object, right?
So my feature request means that if I have a store like this:
const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment (state) {
state.count++
}
}
})
And I have a component like this:
import Vue from 'vue'
import Component from 'vue-class-component'
import {
State,
Getter,
Action,
Mutation,
namespace
} from 'vuex-class'
const ModuleGetter = namespace('path/to/module', Getter)
@Component
export class MyComp extends Vue {
@State('count') count
@Mutation('incremet') increment
}
That the type-annotation would make typescript understand that the count variable of MyComp is a number, since the state variable is a number. And also that typescript would throw an error during compilation, because it can see that increment was misspelled.
Do you think you could try to implement that? Even just having one of those two features would already be awesome.