![](/img/trans.png)
[英]error TS2345: Argument of type 'Menu' is not assignable to parameter of type
[英]TS2345 Argument of type … Is not assignable to parameter of type
我有一个延迟加载的存储,它在整个应用程序存储中返回特定的选择器(即未减少)。 index.ts中的其他选择器已正确减少。 当我尝试从组件调用此选择器时:
this.store.select(getBpFailed).subscribe(res => {
console.log(res);
})
我收到一个打字稿错误,内容为:
error TS2345: Argument of type '(state: State) => boolean' is not assignable to parameter of type ...[entire store model]
另一个奇怪的事情是,当我将鼠标悬停在选择器(在本例中为getBpFailed)上时,类型提示未将其定义为MemorizedSelector,而其他(起作用的)选择器被定义为MemorizedSelector。
关于如何调试的想法? 我在这上面摔了太久了。
我知道了,我直接在组件中引用了reducer的getBpFailed方法,而不是在index.ts文件中使用了选择器。 因此,我得到了整个商店,因为它还没有减少。 哑! 希望这对其他犯同样错误的人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.