getter 的返回值推断有问题
zcf0508 opened this issue · comments
export const counterStore = hamiVuex.store({
// 设置一个唯一名称,方便调试程序和显示错误信息
$name: "counter",
// 定义状态
$state() {
return {
test: {
a: 1,
},
};
},
// ↓↓↓ 这里 testA 的返回值推断是 any 而不是 number
get testA() {
// 这里 this.test.a 的类型能正常推断为 number
return this.test.a;
},
});
如上面代码所示,getter 的返回值不能正常自动推断,需要手动指定返回值的类型。
查找到一个相关issue microsoft/TypeScript#49511 ,不知道能不能解决问题。
我看了类型定义的,感觉没什么问题。所以不是很清楚问题出在哪里