Visitar URL original
fix(react-query*): declare '@types/react' as an optional peer dependency by sukvvon · Pull Request #11728 · TanStack/query · GitHub
Skip to content

fix(react-query*): declare '@types/react' as an optional peer dependency - #11728

Open
sukvvon wants to merge 5 commits into
mainfrom
fix/react-query-types-react-peer
Open

sukvvon wants to merge 5 commits into
mainfrom
fix/react-query-types-react-peer

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

The published type declarations of react-query, react-query-devtools, react-query-next-experimental and react-query-persist-client import React types, so strict package managers need @types/react to be declared. It should be optional, so JavaScript users don't get it auto-installed or see a missing peer warning.

  • Declare "@types/react": "^18 || ^19" as a peer dependency of react-query, react-query-next-experimental and react-query-persist-client. react-query-devtools already declares it.
  • Mark @types/react optional in peerDependenciesMeta in all four packages.
  • In knip.ts, read the ignored dependencies from the optional peer dependencies, like angular-query-experimental does for its optional dependencies, since knip's strict mode excludes optional peers. This replaces the hard-coded '@types/react!' of react-query, react-query-next-experimental and react-query-persist-client, and adds the same for react-query-devtools. Removing a declaration still fails the check.
  • Add a patch changeset for the four packages.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Compatibility
    • React Query packages now support optional React 18 and 19 type definitions. Projects that do not use TypeScript can continue without installing them, while TypeScript projects can install the matching definitions for improved type support.
  • Package Updates
    • Patch releases are planned for React Query, Devtools, Next Experimental, and Persist Client.

@sukvvon sukvvon self-assigned this Sep 29, 2026
@nx-cloud

nx-cloud Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 72d3de2

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 2m 58s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-10 14:39:27 UTC

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

6 package(s) bumped directly, 19 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/query-core 5.104.1 → 5.104.2 Changeset
@tanstack/react-query 5.104.1 → 5.104.2 Changeset
@tanstack/react-query-devtools 5.104.1 → 5.104.2 Changeset
@tanstack/react-query-next-experimental 5.104.1 → 5.104.2 Changeset
@tanstack/react-query-persist-client 5.104.1 → 5.104.2 Changeset
@tanstack/vue-query 5.104.1 → 5.104.2 Changeset
@tanstack/angular-query-experimental 5.104.1 → 5.104.2 Dependent
@tanstack/angular-query-persist-client 5.104.1 → 5.104.2 Dependent
@tanstack/eslint-plugin-query 5.104.1 → 5.104.2 Dependent
@tanstack/lit-query 0.2.26 → 0.2.27 Dependent
@tanstack/preact-query 5.104.1 → 5.104.2 Dependent
@tanstack/preact-query-devtools 5.104.1 → 5.104.2 Dependent
@tanstack/preact-query-persist-client 5.104.1 → 5.104.2 Dependent
@tanstack/query-async-storage-persister 5.104.1 → 5.104.2 Dependent
@tanstack/query-broadcast-client-experimental 5.104.1 → 5.104.2 Dependent
@tanstack/query-devtools 5.104.1 → 5.104.2 Dependent
@tanstack/query-persist-client-core 5.104.1 → 5.104.2 Dependent
@tanstack/query-sync-storage-persister 5.104.1 → 5.104.2 Dependent
@tanstack/solid-query 5.104.1 → 5.104.2 Dependent
@tanstack/solid-query-devtools 5.104.1 → 5.104.2 Dependent
@tanstack/solid-query-persist-client 5.104.1 → 5.104.2 Dependent
@tanstack/svelte-query 6.3.1 → 6.3.2 Dependent
@tanstack/svelte-query-devtools 6.3.1 → 6.3.2 Dependent
@tanstack/svelte-query-persist-client 6.3.1 → 6.3.2 Dependent
@tanstack/vue-query-devtools 6.3.1 → 6.3.2 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11728

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11728

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11728

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11728

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11728

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11728

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11728

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11728

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@11728

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@11728

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11728

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11728

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@11728

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@11728

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11728

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11728

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@11728

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11728

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11728

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@11728

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11728

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11728

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@11728

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11728

commit: 72d3de2

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: TanStack/query/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1e6d7c47-fe0b-4272-b21e-64ac7cef2c06

📥 Commits

Reviewing files that changed from the base of the PR and between d99aede and 72d3de2.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/query/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 62a6aacc-0384-43e0-bab7-5d09383ad83b



📥 Commits

Reviewing files that changed from the base of the PR and between c480694 and d99aede.




📒 Files selected for processing (6)
  • .changeset/react-query-types-react-peer.md
  • knip.ts
  • packages/react-query-devtools/package.json
  • packages/react-query-next-experimental/package.json
  • packages/react-query-persist-client/package.json
  • packages/react-query/package.json



🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/react-query-types-react-peer.md



Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Four React Query packages mark @types/react as an optional peer dependency. Three package manifests specify versions ^18 || ^19. Knip derives ignored dependencies from optional peer-dependency metadata.

Changes

Optional React type peer dependencies

Layer / File(s) Summary
Declare optional React type peers
packages/react-query/package.json, packages/react-query-next-experimental/package.json, packages/react-query-persist-client/package.json, packages/react-query-devtools/package.json, .changeset/react-query-types-react-peer.md
Four package manifests mark @types/react as optional. Three specify the `^18
Derive Knip ignores from package metadata
knip.ts
Knip builds ignored dependency entries from names present in both peerDependencies and peerDependenciesMeta. Four workspaces use the helper.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: lachlancollins





Merge Risk: ⚪ Minimal · up to d99ae

JavaScript consumers can avoid installing React type definitions unnecessarily. No concrete merge-blocking risk is identified; the change is ready for normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to c28b3

The change affects 4 systems.

Changed systems: knip.ts, packages/react-query, packages/react-query-next-experimental, packages/react-query-persist-client

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — knip.ts (service) was modified; 1 changed file maps to changed impact.
  • observed — packages/react-query (library) was modified; 1 changed file maps to changed impact.
  • observed — packages/react-query-next-experimental (library) was modified; 1 changed file maps to changed impact.
  • observed — packages/react-query-persist-client (library) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in knip.ts: The comment and workspace configuration entries for packages/react-query, packages/react-query-next-experimental, and packages/react-query-persist-client were removed, including each @types/react! dependency-ignore setting.
  • observed — Modified behavior in packages/react-query-next-experimental/package.json: Adds @types/react as a peer dependency, accepting versions ^18 or ^19.
  • observed — Modified behavior in packages/react-query-persist-client/package.json: Adds @types/react as a peer dependency, accepting versions 18 or 19.
  • observed — Modified behavior in packages/react-query/package.json: Adds @types/react as a peer dependency supporting versions 18 and 19.





Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely identifies the main change: declaring @types/react as an optional peer dependency across the React Query packages.
Description check Passed The description follows the required template, explains the motivation and implementation, completes the checklist, and identifies the release impact and changeset.



✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR





🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR






Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.73 KB (0%)
react minimal 8.58 KB (0%)

@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 72d3de2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@tanstack/react-query Patch
@tanstack/react-query-devtools Patch
@tanstack/react-query-next-experimental Patch
@tanstack/react-query-persist-client Patch
@tanstack/angular-query-experimental Patch
@tanstack/eslint-plugin-query Patch
@tanstack/preact-query-devtools Patch
@tanstack/preact-query-persist-client Patch
@tanstack/preact-query Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-core Patch
@tanstack/query-devtools Patch
@tanstack/query-persist-client-core Patch
@tanstack/query-sync-storage-persister Patch
@tanstack/solid-query-devtools Patch
@tanstack/solid-query-persist-client Patch
@tanstack/solid-query Patch
@tanstack/vue-query Patch
@tanstack/lit-query Patch
@tanstack/svelte-query Patch
@tanstack/svelte-query-devtools Patch
@tanstack/vue-query-devtools Patch
@tanstack/svelte-query-persist-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"typescript": "catalog:"
},
"peerDependencies": {
"@types/react": "^18 || ^19",

@unrevised6419 unrevised6419 Oct 10, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, @sukvvon please make this optional.

@sukvvon sukvvon changed the title fix(react-query*): declare '@types/react' as a peer dependency like 'react-query-devtools' fix(react-query*): declare '@types/react' as an optional peer dependency Oct 10, 2026
@sukvvon

sukvvon commented Oct 10, 2026

Copy link
Copy Markdown
Member Author

@TkDodo Updated in d99aede: @types/react is now an optional peer (peerDependenciesMeta) in all four packages, including react-query-devtools, so JavaScript users don't get it auto-installed, and knip.ts reads the ignores from those optional peers instead of hard-coding them.

@sukvvon
sukvvon requested a review from TkDodo October 10, 2026 13:24

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants