【问题标题】:What is the type of vuex 'vuex-class' decoratorvuex 'vuex-class' 装饰器的类型是什么
【发布时间】:2019-05-15 14:43:50
【问题描述】:
我为我们的 typescript 项目启用了“no-implicit-any”规则,但我无法为所有“vuex-class”装饰器定义类型。
例如,如果导入命名空间的操作
@(namespace('foo').Action('bar')) foobar: any;
...这个模块的类型是什么?
我不想关闭“no-implicit-any”规则,并希望在我的项目中定义和删除所有“any”。
【问题讨论】:
标签:
typescript
vue.js
vuex
【解决方案1】:
您将其设置为 store 方法的签名:
鉴于商店:
bar ({ commit }: SomeActionContext, newValue: string) {
commit('setValue', { value: newValue})
}
在您的组件中:
@(namespace('foo').Action('bar'))
private bar!: (newValue: string) => void