Skip to content

Export hook options types for RTK Query hooks#5218

Merged
EskiMojo14 merged 3 commits intoreduxjs:masterfrom
veeceey:fix/issue-5172-export-hook-options-types
Feb 10, 2026
Merged

Export hook options types for RTK Query hooks#5218
EskiMojo14 merged 3 commits intoreduxjs:masterfrom
veeceey:fix/issue-5172-export-hook-options-types

Conversation

@veeceey
Copy link
Contributor

@veeceey veeceey commented Feb 8, 2026

Summary

Exports UseQuerySubscriptionOptions, UseQueryStateOptions, and UseMutationStateOptions from @reduxjs/toolkit/query/react to allow users to directly reference these types without using Parameters<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 the Parameters utility type to extract the options type, which is verbose and less discoverable:

// Current workaround
options?: Parameters<TypedUseQuery<...>>[1]

With these types exported, it becomes much cleaner:

// After this change
options?: UseQuerySubscriptionOptions & UseQueryStateOptions<...>

Changes

  • Added exports for UseQuerySubscriptionOptions, UseQueryStateOptions, and UseMutationStateOptions in /packages/toolkit/src/query/react/index.ts

Test Plan

  • TypeScript compilation succeeds
  • Existing tests pass
  • Types are properly exported and accessible to consumers

Fixes #5172

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
@codesandbox
Copy link

codesandbox bot commented Feb 8, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 8, 2026

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:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

@netlify
Copy link

netlify bot commented Feb 8, 2026

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 20387a1
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/698b65b344ce94000845993b
😎 Deploy Preview https://deploy-preview-5218--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@aryaemami59 aryaemami59 added RTK-Query Issues related to Redux-Toolkit-Query TypeScript Issues related to TypeScript. labels Feb 8, 2026
@aryaemami59
Copy link
Member

aryaemami59 commented Feb 8, 2026

We should probably do this as well

https://github.com/veeceey/redux-toolkit/blob/9aad60df2e3d74cd94e18d9bdf65b7e44649351e/packages/toolkit/src/query/react/buildHooks.ts#L527C1-L598C2

/**
- * @internal
+ * @public
 */
export type UseQueryStateOptions<

@EskiMojo14
Copy link
Collaborator

instead of exporting these directly, we should have Typed<name> wrappers as with the others

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>
@veeceey
Copy link
Contributor Author

veeceey commented Feb 10, 2026

Thanks for the feedback @EskiMojo14 and @aryaemami59! I've updated the PR in the latest commit (97bc40f) to use Typed<name> wrappers for all the exported hook option types, following the existing pattern:

  • TypedUseQuerySubscriptionOptions (simple alias since the base type has no generics)
  • TypedUseQueryStateOptions (already existed with proper generics, now re-exported)
  • TypedUseMutationStateOptions (new, with generic parameters)

The UseQueryStateOptions was also changed from @internal to @public as suggested. Let me know if anything else is needed!

@EskiMojo14 EskiMojo14 merged commit b5aa49c into reduxjs:master Feb 10, 2026
47 checks passed
@EskiMojo14
Copy link
Collaborator

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RTK-Query Issues related to Redux-Toolkit-Query TypeScript Issues related to TypeScript.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export the options types for hooks such as useQuery, useLazyQuery, and useMutation.

3 participants