redux-toolkit
redux-toolkit copied to clipboard
TS error on injected API optimistic update
Hi, I'm getting a TS error when I try to use optimistic updates on a code-split API instance. The thunk works correctly and updates the data correctly, but TypeScript isn't happy. Here's the thunk:
const dispatch = useAppDispatch();
...
dispatch(
beneficiariesApi.util.updateQueryData(
'getBeneficiary',
beneficiaryId,
(draft) => {
draft.data.attributes.trusted = true;
return draft;
}
)
);
TS error:
No overload matches this call.
The last overload gave the following error.
Argument of type 'ThunkAction<PatchCollection, RootState<UpdateDefinitions<{ getCountries: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, "ReferenceData", CountryPage, "api">; getCurrencies: QueryDefinition<...>; }, "ReferenceData" | ... 1 more ... | "Beneficiary", never> ...' is not assignable to parameter of type 'UnknownAction'.ts(2769)
I'm not sure what I'm doing wrong, as this endpoint is definitely defined within this set of endpoints.