I have this helper function what I want to call after, with this signature :
export const fetchPaginated = async <T>(
callback: (params: any) => Promise<T>,
{
page = 1,
pageSize,
}: { page?: number; pageSize?: number; [x: string]: any },
previousData = [] as Array<T>
): Promise<T | undefined>
I trying to use it this way:
...
fetchPaginated<Modules>(getModules({}), {}),
...
When I call it is shows me always the same error:
Argument of type 'Promise<Modules>' is not assignable to parameter of type '(params: any) => Promise<Modules>'.
I already tried to changes the types, but nothing fixed the error
CodePudding user response:
Argument of type 'Promise<Modules>' is not assignable to '(params: any) => Promise<Modules>'
This means that getModules({})
- is not of type
(params: any) => Promise<Modules>
- is of type
Promise<Modules>
More
Based on the error, it seems the fix will be:
...
fetchPaginated<Modules>(getModules, {}),
...