Export hook options types for RTK Query hooks#5218
Export hook options types for RTK Query hooks#5218EskiMojo14 merged 3 commits intoreduxjs:masterfrom
Conversation
Exports UseQuerySubscriptionOptions, UseQueryStateOptions, and UseMutationStateOptions from @reduxjs/toolkit/query/react to allow users to reference these types directly without using Parameters<T>. Fixes reduxjs#5172
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 20387a1:
|
✅ Deploy Preview for redux-starter-kit-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
We should probably do this as well /**
- * @internal
+ * @public
*/
export type UseQueryStateOptions< |
|
instead of exporting these directly, we should have |
Address reviewer feedback: instead of exporting UseQuerySubscriptionOptions, UseQueryStateOptions, and UseMutationStateOptions directly, export them as Typed<name> wrappers following the existing codebase convention. Also change UseQueryStateOptions JSDoc tag from @internal to @public. - Add TypedUseQuerySubscriptionOptions (simple alias, no generics needed) - Add TypedUseMutationStateOptions (pre-typed wrapper with ResultType, QueryArg, BaseQuery, SelectedResult generic params) - Update index.ts to export the Typed wrappers instead of raw types - TypedUseQueryStateOptions was already present and exported Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the feedback @EskiMojo14 and @aryaemami59! I've updated the PR in the latest commit (
The |
|
thanks! |
Summary
Exports
UseQuerySubscriptionOptions,UseQueryStateOptions, andUseMutationStateOptionsfrom@reduxjs/toolkit/query/reactto allow users to directly reference these types without usingParameters<T>utility type workaround.Motivation
Currently, when building wrapper hooks that accept the same options as RTK Query hooks (
useQuery,useLazyQuery,useMutation), developers must use theParametersutility type to extract the options type, which is verbose and less discoverable:With these types exported, it becomes much cleaner:
Changes
UseQuerySubscriptionOptions,UseQueryStateOptions, andUseMutationStateOptionsin/packages/toolkit/src/query/react/index.tsTest Plan
Fixes #5172