简体   繁体   中英

TS2345 Argument of type … Is not assignable to parameter of type

I have a lazy loaded store that is returning a specific selectors with the entire application store (ie it is not reduced). The other selectors in this index.ts are reduced correctly. When I try to call this selector from a component:

this.store.select(getBpFailed).subscribe(res => {
    console.log(res);
})

I get a typescript error that says:

error TS2345: Argument of type '(state: State) => boolean' is not assignable to parameter of type ...[entire store model]

Another odd thing is that when I hover over the selector (in this case getBpFailed) the type hinting does not define it as a MemorizedSelector, where other (working) selectors they are defined as a MemorizedSelector.

Thoughts on how to debug? I've been banging my head off the wall for too long on this one.

I figured it out, I was referencing the reducer getBpFailed method directly in my component, rather then using the selector in the index.ts file. Thus I was getting the entire store because it wasn't reduced yet. Dumb! Hope this helps anyone else that makes the same mistake.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM