upd(vue-query): Improve queryOptions() type
๐ฏ Changes
I changed UseQueryOptions and its derivatives UndefinedInitialQueryOptions / DefinedInitialQueryOptions to have base non-ref cases to later differentiate them in queryOptions function. I don't think I can foresee possible implications of this as I am a novice, but I'm thinking nothing bad will happen from splitting the types like that
โ Checklist
- [X] I have followed the steps in the Contributing guide.
- [X] I have tested this code locally with
pnpm run test:pr.
๐ Release Impact
- [X] This change affects published code, and I have generated a changeset. I dont really know how this works, but I've done it I guess
Summary by CodeRabbit
- Refactor
- Improved TypeScript type definitions for query options and initial data to better support both plain and Vue-reactive configurations.
- Chores
- Added a patch-level changeset entry updating the package version.
๐ฆ Changeset detected
Latest commit: 8d3f77a4742dbfcf412383a631e55fdf4d701ce6
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 2 packages
| Name | Type |
|---|---|
| @tanstack/vue-query | 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
Walkthrough
Refactors vue-query TypeScript types to support Vue reactive wrappers (Ref/ComputedRef) for query options, splitting UseQueryOptions into base/ref variants and updating queryOptions overloads to use generic conditional return types. Also adds a changeset marking a patch release.
Changes
| Cohort / File(s) | Summary |
|---|---|
Changeset entry \.changeset/seven-apes-boil.md |
Adds a changeset noting a patch release that signals changes to the public UseQueryOptions types. |
Query options overloads packages/vue-query/src/queryOptions.ts |
Rewrites queryOptions overloads to accept generic TOptions/TReturnQueryKey and return conditional intersections: Ref-aware or base-defined option variants depending on presence of a value property. Keeps passthrough overload. |
useQuery type hierarchy packages/vue-query/src/useQuery.ts |
Replaces the monolithic UseQueryOptions with UseQueryOptionsBase, UseQueryOptionsRef, and combinable variants; splits initialData variants into Defined/Undefined + Base/Ref forms and updates useQuery overloads to use the new public option types. |
Estimated code review effort
๐ฏ 4 (Complex) | โฑ๏ธ ~45 minutes
Possibly related PRs
- TanStack/query#9668 โ Related changes to
queryOptionsTypeScript signatures in the core query package. - TanStack/query#9634 โ Related refactor introducing MaybeRef/reactive-wrapper typing patterns for infinite-query option overloads.
Suggested reviewers
- manudeli
- DamianOsipiuk
Poem
๐ฐ Hop, hop, the types rearrange,
Ref and Base across the range,
Options snug in Vue's embrace,
Patch released โ a tidy trace,
I nibble bugs and leave a trace ๐ฅ
Pre-merge checks and finishing touches
โ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
โ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | โ Passed | The title "upd(vue-query): Improve queryOptions() type" is clearly and specifically related to the core change in the pull request. The changes focus on improving the type system for the queryOptions() function by introducing generic type parameters, conditional return types, and refactoring UseQueryOptions to support both base and reactive ref variants. The title is concise, avoids vague language, and accurately summarizes the primary modification that a teammate would understand when scanning commit history. |
| Description Check | โ Passed | The pull request description includes all three required sections from the template: the Changes section explains that UseQueryOptions and its derivatives were modified to include base non-ref cases for differentiation in the queryOptions function, the Checklist section has both items marked as completed, and the Release Impact section is checked with a note indicating a changeset was generated. While the Changes section could provide more technical depth about the conditional type system and the specific motivations for splitting the types, all required information is present and the description meets the threshold for completeness as most critical sections are filled out with meaningful content. |
โจ Finishing touches
- [ ] ๐ Generate docstrings
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
๐ค Nx Cloud AI Fix Eligible
An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.
To disable these notifications, a workspace admin can disable them in workspace settings.
View your CI Pipeline Execution โ for commit 8d3f77a4742dbfcf412383a631e55fdf4d701ce6
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
โ Failed | 1m 5s | View โ |
nx run-many --target=build --exclude=examples/*... |
โ Failed | 6s | View โ |
โ๏ธ Nx Cloud last updated this comment at 2025-10-17 09:53:13 UTC