It is probably a noobish question, but how do I deal with the Typescript error TS2344?
Type 'State' does not satisfy the constraint '(state: any, ...args: any[]) => any'.
Here is the code fragement of my sagas.ts
where the error occurs
function* loadPageFull(action: Actions.LoadPageFullAction ) {
if (!action.id)
return;
const currentPageFull: Interfaces.PageFull =
yield (select<Top.State>(Selectors.getPageFull(action.id))); // <-- error occurs here
if (!currentPageFull || action.forceReload) {
// here we query the API of the backend and return some JSON
}
}
The problem seems to be the Top.State
in the line with the yield
. The curious thing is that I did not have the error before updating Typescript to version 3.6.4.
EDIT: The getPageFull
is defined in selectors.ts
as
const getPageFullInner = (state: State, id: number) => state.pagesFull.get(id);
export const getPageFull = (id: number) => (state: Top.State)
=> getPageFullInner(foobar(state), id);
The foobar()
function is also defined there
export const foobar = (state: State) => state.foobar;