Skip to content

Conversation

@TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Nov 16, 2025

closes #9871

Summary by CodeRabbit

  • Bug Fixes

    • Improved TypeScript typings for query filters: supports unions of tuple keys with different lengths and allows direct key matches as well as tuple-prefix matches.
  • Tests

    • Added test coverage validating query key type handling for unions of varying tuple lengths.

@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2025

🦋 Changeset detected

Latest commit: 601f14b

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

This PR includes changesets to release 19 packages
Name Type
@tanstack/query-core Patch
@tanstack/angular-query-experimental Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-persist-client-core Patch
@tanstack/query-sync-storage-persister Patch
@tanstack/react-query Patch
@tanstack/solid-query Patch
@tanstack/svelte-query Patch
@tanstack/vue-query Patch
@tanstack/angular-query-persist-client Patch
@tanstack/react-query-persist-client Patch
@tanstack/solid-query-persist-client Patch
@tanstack/svelte-query-persist-client Patch
@tanstack/react-query-devtools Patch
@tanstack/react-query-next-experimental Patch
@tanstack/solid-query-devtools Patch
@tanstack/svelte-query-devtools Patch
@tanstack/vue-query-devtools 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Widened the QueryFilters.queryKey type to accept either an exact TQueryKey or TuplePrefixes<TQueryKey>. Added a type test covering unions of readonly tuples and a changeset entry documenting the patch-level typing fix. No runtime logic changes.

Changes

Cohort / File(s) Summary
Type Definition Update
packages/query-core/src/utils.ts
Changed interface QueryFilters<TQueryKey>.queryKey from TuplePrefixes<TQueryKey> to TQueryKey | TuplePrefixes<TQueryKey> (type widening; public declaration update).
Type Tests
packages/query-core/src/__tests__/utils.test-d.tsx
Added a type-level test that verifies unions of readonly tuples with different lengths can be used as queryKey in invalidateQueries without type errors.
Changeset
.changeset/orange-boxes-visit.md
Added changeset entry describing the patch release and the types-related fix (no code/runtime changes).

Sequence Diagram(s)

(omitted — changes are type-level only; no runtime control-flow modifications)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review the QueryFilters type change for backwards compatibility and unintended widening risks.
  • Verify the new test case correctly reproduces the readonly/unions scenario and that CI type checks pass.
  • Confirm no downstream call sites rely on the previous narrower shape.

Possibly related PRs

Poem

🐰 I nibbled types by moonlit beams,

readonly keys and unioned dreams,
A wider hug for query keys,
Now const arrays rest at ease,
Hooray — the types are stitched in seams! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only contains 'closes #9871' without explaining the changes, motivation, or checklist completion status as required by the template. Add a detailed description under the '🎯 Changes' section explaining the type modification and complete the '✅ Checklist' with implementation details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: preserving readonly type information in QueryFilter matching to fix the regression with readonly query keys.
Linked Issues check ✅ Passed The PR successfully addresses issue #9871 by widening QueryFilters.queryKey to accept 'TQueryKey | TuplePrefixes', preserving readonly types while supporting partial matching.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the readonly type issue: changeset documentation, type definition update, and test coverage for union types with readonly arrays.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7258440 and 601f14b.

📒 Files selected for processing (1)
  • .changeset/orange-boxes-visit.md (1 hunks)

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

@nx-cloud
Copy link

nx-cloud bot commented Nov 16, 2025

View your CI Pipeline Execution ↗ for commit 601f14b

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

☁️ Nx Cloud last updated this comment at 2025-11-16 18:19:57 UTC

@TkDodo TkDodo marked this pull request as ready for review November 16, 2025 17:57
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 16, 2025

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 7258440

@github-actions
Copy link
Contributor

github-actions bot commented Nov 16, 2025

Sizes for commit 601f14b:

Branch Bundle Size
Main
This PR

@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.81%. Comparing base (6226325) to head (601f14b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9878       +/-   ##
===========================================
+ Coverage   45.78%   59.81%   +14.03%     
===========================================
  Files         200      129       -71     
  Lines        8413     5627     -2786     
  Branches     1923     1526      -397     
===========================================
- Hits         3852     3366      -486     
+ Misses       4113     1956     -2157     
+ Partials      448      305      -143     
Components Coverage Δ
@tanstack/angular-query-experimental 93.85% <ø> (ø)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister 43.85% <ø> (ø)
@tanstack/query-broadcast-client-experimental 24.39% <ø> (ø)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core 97.38% <ø> (ø)
@tanstack/query-devtools 3.48% <ø> (ø)
@tanstack/query-persist-client-core 80.00% <ø> (ø)
@tanstack/query-sync-storage-persister 84.61% <ø> (ø)
@tanstack/query-test-utils ∅ <ø> (∅)
@tanstack/react-query 96.01% <ø> (ø)
@tanstack/react-query-devtools 10.00% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query 77.81% <ø> (ø)
@tanstack/solid-query-devtools 61.90% <ø> (ø)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query 71.28% <ø> (ø)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TkDodo TkDodo merged commit 8e2e174 into main Nov 16, 2025
5 of 6 checks passed
@TkDodo TkDodo deleted the feature/9871 branch November 16, 2025 18:17
@github-actions github-actions bot mentioned this pull request Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Partial QueryFilter matching breaks readonly query keys

2 participants