【问题标题】:TS2345 Argument of type ... Is not assignable to parameter of typeTS2345 类型参数...不可分配给类型参数
【发布时间】:2018-08-10 00:51:34
【问题描述】:

我有一个延迟加载的存储,它返回一个带有整个应用程序存储的特定选择器(即它没有减少)。此 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。

关于如何调试的想法?在这个问题上,我已经把头从墙上撞了太久了。

【问题讨论】:

    标签: angular typescript ngrx ngrx-store ngrx-store-4.0


    【解决方案1】:

    我想通了,我是在我的组件中直接引用 reducer getBpFailed 方法,而不是在 index.ts 文件中使用选择器。因此我得到了整个商店,因为它还没有减少。哑的!希望这可以帮助其他犯同样错误的人。

    【讨论】:

      猜你喜欢
      • 2018-02-09
      • 2022-11-21
      • 2021-05-17
      • 2018-10-19
      • 1970-01-01
      • 2021-08-19
      • 2017-07-14
      • 1970-01-01
      • 2017-02-07
      相关资源
      最近更新 更多