Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Contact Details
No response
What should this feature add?
When we use RTK Query in the listener middleware, we'd like to get type safety on actions.
This needs some TypeScript magic, thanks to RTK maintainer on discord:
`type TypeGuard = {
(input: unknown): input is T;
};
type TypeGuardFor<T extends TypeGuard> = T extends TypeGuard
? U
: never;
// in startAppListening
matcher: (
action
): action is TypeGuardFor<
typeof imagesApi.endpoints.listImages.matchFulfilled
> =>
imagesApi.endpoints.listImages.matchFulfilled(action) &&
action.meta.arg.queryCacheKey ===
getListImagesUrl({ categories: IMAGE_CATEGORIES }),`
Alternatives
No response
Aditional Content
No response