Wanting to incorporate automatic behaviors in RTK Query, I decided to implement debounced mutations and handle optimistic updates before the actual mutation request is made. The implementation has been successful so far.
However, I am now focusing on getting the Typescript suggestions correct. This entails extending the generic type interface MutationExtraOptions provided by RTK Query.
Unfortunately, my efforts in doing so have not yielded the desired results:
declare module '@reduxjs/toolkit/query/react' {
export interface MutationExtraOptions<
TagTypes extends string,
ResultType,
QueryArg,
BaseQuery extends BaseQueryFn,
ReducerPath extends string = string
> {
optimisticUpdates?: { (args: QueryArg): any[]; }[];
}
}
This is how my implementation currently looks like:
https://i.sstatic.net/BO9V7nMz.png
The issue I'm facing is that VS-code does not recognize the optimisticUpdates
property.