Skip to content

fix(vue-query): fix type of queryOptions to allow plain properies or getters#10452

Merged
DamianOsipiuk merged 1 commit intomainfrom
do/fix-query-options-types
Apr 11, 2026
Merged

fix(vue-query): fix type of queryOptions to allow plain properies or getters#10452
DamianOsipiuk merged 1 commit intomainfrom
do/fix-query-options-types

Conversation

@DamianOsipiuk
Copy link
Copy Markdown
Contributor

@DamianOsipiuk DamianOsipiuk commented Apr 11, 2026

🎯 Changes

Fixes: #7892

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 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

  • Bug Fixes

    • Fixed queryOptions typing to accept plain properties and/or getter factories.
  • New Features

    • Exposed new QueryOptions types (including variants for required/optional initial data).
    • QueryClient methods and fetchQuery now accept reactive values or zero-arg factory functions.
    • Improved TypeScript inference for queryOptions and useQueries.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 11, 2026

📝 Walkthrough

Walkthrough

Adds getter/thunk support across vue-query: new QueryOptions types and MaybeGetter, a toValueDeep utility, queryOptions overloads accepting thunks, QueryClient overloads accepting thunks for filters/options, an index type re-export, type-test updates, and a changeset entry.

Changes

Cohort / File(s) Summary
Changeset
.changeset/three-pillows-enter.md
New changeset entry documenting the patch release for getter/thunk support in queryOptions.
Public API / Exports
packages/vue-query/src/index.ts
Re-exported the QueryOptions type from queryOptions to expose the new type-level API.
Type Utilities
packages/vue-query/src/types.ts
Added `export type MaybeGetter = T
Core Types & Overloads
packages/vue-query/src/queryOptions.ts
Introduced exported QueryOptions, DefinedInitialQueryOptions, UndefinedInitialQueryOptions; added overloads for queryOptions accepting thunks returning those types (returns typed thunk with queryKey: DataTag<...>).
Runtime Utilities
packages/vue-query/src/utils.ts
Added `toValueDeep(source: (() => T)
QueryClient behavior
packages/vue-query/src/queryClient.ts
Updated overloads/signatures so invalidateQueries and fetchQuery accept filters/options as MaybeRefDeep<...> or zero-arg factories () => ...; implementation casts factory inputs and delegates normalization (via deep-unref/clone) before scheduling refetches.
Type-level tests
packages/vue-query/src/__tests__/queryOptions.test-d.ts, packages/vue-query/src/__tests__/useQueries.test-d.ts
Adjusted/tested TypeScript inference: moved @ts-expect-error placement, added getter-based queryOptions scenarios, and new assertions verifying queryFn/queryKey/staleTime access and useQueries data inference for plain and select-mapped results.
Runtime tests
packages/vue-query/src/__tests__/queryOptions.test.ts
Switched input type to QueryOptions, captured queryOptions(object) in options variable, and asserted referential equality (toBe) is preserved.

Sequence Diagram

sequenceDiagram
    participant User
    participant queryOptions
    participant QueryClient
    participant toValueDeep
    participant Core

    User->>queryOptions: provide plain object or zero-arg getter
    alt Getter path
        queryOptions->>queryOptions: accept/return thunk overload
        queryOptions-->>User: thunk that yields options
        User->>QueryClient: call invalidateQueries/fetchQuery with thunk
    else Plain value path
        queryOptions->>queryOptions: accept direct overload
        User->>QueryClient: call invalidateQueries/fetchQuery with value
    end

    QueryClient->>toValueDeep: normalize filters/options (invoke if function)
    toValueDeep-->>QueryClient: normalized plain value
    QueryClient->>Core: forward normalized filters/options to core API
    Core-->>QueryClient: result/ack
    QueryClient-->>User: update/refetch behavior
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibble types and chew on thunks with glee,
Options now hop free—from getters they flee.
Deep-unwrapped carrots and cloned-value delight,
QueryClient hums through the soft moonlight. ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description lacks substantive implementation details in the Changes section, containing only a placeholder comment and unchecked checklists. Add a detailed explanation of what was changed (e.g., type modifications to queryOptions), why these changes fix the issue, and confirm both contributing guide compliance and test execution were completed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing the type of queryOptions in vue-query to allow plain properties or getters, which aligns with the substantial type updates across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch do/fix-query-options-types

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 and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 11, 2026

View your CI Pipeline Execution ↗ for commit 0649ccb

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

☁️ Nx Cloud last updated this comment at 2026-04-11 15:53:44 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 11, 2026

🚀 Changeset Version Preview

2 package(s) bumped directly, 22 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/vue-query 5.97.0 → 5.98.0 Changeset
@tanstack/angular-query-experimental 5.97.0 → 5.98.0 Dependent
@tanstack/angular-query-persist-client 5.97.0 → 5.98.0 Dependent
@tanstack/eslint-plugin-query 5.97.0 → 5.98.0 Dependent
@tanstack/preact-query 5.97.0 → 5.98.0 Dependent
@tanstack/preact-query-devtools 5.97.0 → 5.98.0 Dependent
@tanstack/preact-query-persist-client 5.97.0 → 5.98.0 Dependent
@tanstack/query-async-storage-persister 5.97.0 → 5.98.0 Dependent
@tanstack/query-broadcast-client-experimental 5.97.0 → 5.98.0 Dependent
@tanstack/query-core 5.97.0 → 5.98.0 Dependent
@tanstack/query-devtools 5.97.0 → 5.98.0 Dependent
@tanstack/query-persist-client-core 5.97.0 → 5.98.0 Dependent
@tanstack/query-sync-storage-persister 5.97.0 → 5.98.0 Dependent
@tanstack/react-query 5.97.0 → 5.98.0 Dependent
@tanstack/react-query-devtools 5.97.0 → 5.98.0 Dependent
@tanstack/react-query-next-experimental 5.97.0 → 5.98.0 Dependent
@tanstack/react-query-persist-client 5.97.0 → 5.98.0 Dependent
@tanstack/solid-query 5.97.0 → 5.98.0 Dependent
@tanstack/solid-query-devtools 5.97.0 → 5.98.0 Dependent
@tanstack/solid-query-persist-client 5.97.0 → 5.98.0 Dependent

🟩 Patch bumps

Package Version Reason
@tanstack/vue-query-devtools 6.1.14 → 6.1.15 Changeset
@tanstack/svelte-query 6.1.14 → 6.1.15 Dependent
@tanstack/svelte-query-devtools 6.1.14 → 6.1.15 Dependent
@tanstack/svelte-query-persist-client 6.1.14 → 6.1.15 Dependent

@DamianOsipiuk DamianOsipiuk force-pushed the do/fix-query-options-types branch from 47e4c6b to 0649ccb Compare April 11, 2026 15:51
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/vue-query/src/queryClient.ts (1)

304-310: ⚠️ Potential issue | 🔴 Critical

Implementation signature and body don't handle getter functions.

The overload (lines 286-296) accepts (() => FetchQueryOptions<...>), but the implementation signature (lines 305-307) only declares MaybeRefDeep<FetchQueryOptions<...>>. When a getter is passed, it will be mishandled by cloneDeepUnref the same way as in invalidateQueries.

🐛 Proposed fix to handle getters in fetchQuery
   fetchQuery<
     TQueryFnData,
     TError = DefaultError,
     TData = TQueryFnData,
     TQueryKey extends QueryKey = QueryKey,
     TPageParam = never,
   >(
-    options: MaybeRefDeep<
-      FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
-    >,
+    options:
+      | MaybeRefDeep<
+          FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
+        >
+      | (() => FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>),
   ): Promise<TData> {
-    return super.fetchQuery(cloneDeepUnref(options))
+    return super.fetchQuery(
+      cloneDeepUnref(
+        toValueDeep(options) as MaybeRefDeep<
+          FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
+        >,
+      ),
+    )
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/queryClient.ts` around lines 304 - 310, The
implementation of fetchQuery doesn't handle getter functions even though an
overload accepts (() => FetchQueryOptions<...>); update the implementation
signature to accept either a getter or MaybeRefDeep (e.g., options:
MaybeRefDeep<FetchQueryOptions<...>> | (() => FetchQueryOptions<...>)) and
inside fetchQuery resolve the getter before cloning: detect if options is a
function (the getter) and call it to obtain the options, then pass the resolved
value to cloneDeepUnref and forward to super.fetchQuery; reference fetchQuery
and cloneDeepUnref to locate where to change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/three-pillows-enter.md:
- Line 5: Typo in the changeset title string "fix(vue-query): fix type of
queryOptions to allow plain properies or getters" — change "properies" to
"properties" so the sentence reads "...allow plain properties or getters";
update that exact text in the .changeset entry to correct the spelling.

In `@packages/vue-query/src/queryClient.ts`:
- Line 3: The file imports toValueDeep but never uses it; update the call sites
where query keys or args are processed (notably in functions/methods named
invalidateQueries and fetchQuery) to resolve getter functions before
deep-unwrapping by passing inputs through toValueDeep and then into
cloneDeepUnref (e.g., replace direct cloneDeepUnref(someInput) with
cloneDeepUnref(toValueDeep(someInput))). This ensures getter-based keys/params
are evaluated prior to cloning and keeps the existing import usage.
- Around line 205-209: The public overload for invalidateQueries in
queryClient.ts is missing getter support for the options parameter; update the
overload’s options type to include a getter by changing options?:
MaybeRefDeep<InvalidateOptions> to options?: MaybeRefDeep<InvalidateOptions> |
(() => InvalidateOptions) (or (() => MaybeRefDeep<InvalidateOptions>) to match
your ref handling) so the public signature matches the implementation that
accepts (() => InvalidateOptions); adjust the overload for invalidateQueries and
ensure references to InvalidateOptions and MaybeRefDeep remain consistent.
- Around line 216-221: The code currently passes potential getter functions
directly into cloneDeepUnref (e.g., when building filtersCloned and
optionsCloned), but cloneDeepUnref(unrefGetters=false) won't invoke root-level
getters so function objects slip through; fix by first resolving any getters
with toValueDeep on the original inputs (filters and options) and then pass the
resolved values into cloneDeepUnref (i.e., replace the direct
cloneDeepUnref(filters as MaybeRefDeep<...>) and cloneDeepUnref(options as
MaybeRefDeep<...>) flows with toValueDeep(...) followed by cloneDeepUnref(...)
so root-level getter functions are invoked before cloning).

In `@packages/vue-query/src/queryOptions.ts`:
- Around line 25-27: The mapped type for QueryOptions incorrectly forces the
'enabled' property to be a getter only; change the mapping for Property extends
'enabled' in QueryOptions so it accepts the core library's Enabled type (boolean
| (query)=>boolean) rather than only a no-arg function. Locate the mapped type
in QueryOptions (the clause currently returning "() => Enabled<...>") and
replace it with the correct Enabled<TQueryFnData, TError, TQueryData,
DeepUnwrapRef<TQueryKey>> type (or a union of boolean and the predicate
signature) so that plain true/false and predicate functions are both accepted;
ensure QueryObserverOptions usage remains unchanged.

In `@packages/vue-query/src/utils.ts`:
- Around line 113-114: toValueDeep currently returns source() directly when
source is a function, skipping deep unref/clone normalization and causing
inconsistent behavior; modify toValueDeep so it always passes the resolved value
through cloneDeepUnref (e.g., compute const resolved = isFunction(source) ?
source() : source and return cloneDeepUnref(resolved)) so both function and
non-function inputs get identical deep-unref/clone treatment; keep references to
toValueDeep, isFunction, cloneDeepUnref and MaybeRefDeep in the change.

---

Outside diff comments:
In `@packages/vue-query/src/queryClient.ts`:
- Around line 304-310: The implementation of fetchQuery doesn't handle getter
functions even though an overload accepts (() => FetchQueryOptions<...>); update
the implementation signature to accept either a getter or MaybeRefDeep (e.g.,
options: MaybeRefDeep<FetchQueryOptions<...>> | (() => FetchQueryOptions<...>))
and inside fetchQuery resolve the getter before cloning: detect if options is a
function (the getter) and call it to obtain the options, then pass the resolved
value to cloneDeepUnref and forward to super.fetchQuery; reference fetchQuery
and cloneDeepUnref to locate where to change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3298b37d-8c6f-49e8-b9b3-09276d25ac36

📥 Commits

Reviewing files that changed from the base of the PR and between b97513f and 47e4c6b.

📒 Files selected for processing (9)
  • .changeset/three-pillows-enter.md
  • packages/vue-query/src/__tests__/queryOptions.test-d.ts
  • packages/vue-query/src/__tests__/queryOptions.test.ts
  • packages/vue-query/src/__tests__/useQueries.test-d.ts
  • packages/vue-query/src/index.ts
  • packages/vue-query/src/queryClient.ts
  • packages/vue-query/src/queryOptions.ts
  • packages/vue-query/src/types.ts
  • packages/vue-query/src/utils.ts

'@tanstack/vue-query': patch
---

fix(vue-query): fix type of queryOptions to allow plain properies or getters
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typo in changeset text.

properies should be properties in the release note sentence.

📝 Proposed edit
-fix(vue-query): fix type of queryOptions to allow plain properies or getters
+fix(vue-query): fix type of queryOptions to allow plain properties or getters
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fix(vue-query): fix type of queryOptions to allow plain properies or getters
fix(vue-query): fix type of queryOptions to allow plain properties or getters
🧰 Tools
🪛 LanguageTool

[grammar] ~5-~5: Ensure spelling is correct
Context: ...fix type of queryOptions to allow plain properies or getters

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/three-pillows-enter.md at line 5, Typo in the changeset title
string "fix(vue-query): fix type of queryOptions to allow plain properies or
getters" — change "properies" to "properties" so the sentence reads "...allow
plain properties or getters"; update that exact text in the .changeset entry to
correct the spelling.

Comment on lines +216 to +221
const filtersCloned = cloneDeepUnref(
filters as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>,
)
const optionsCloned = cloneDeepUnref(
options as MaybeRefDeep<InvalidateOptions>,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Getter functions passed as arguments will not be invoked.

When a getter function () => InvalidateQueryFilters is passed, the current implementation casts it to MaybeRefDeep<T> and passes it directly to cloneDeepUnref. However, cloneDeepUnref with default parameters (unrefGetters=false) does not invoke root-level getter functions—it only handles nested getters for queryKey at level 1.

This means the function object itself (not its return value) will be passed to query-core, causing silent runtime failures.

The getter should be resolved first using toValueDeep before cloning:

🐛 Proposed fix to resolve getters before cloning
-    const filtersCloned = cloneDeepUnref(
-      filters as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>,
-    )
-    const optionsCloned = cloneDeepUnref(
-      options as MaybeRefDeep<InvalidateOptions>,
-    )
+    const filtersCloned = cloneDeepUnref(
+      toValueDeep(filters) as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>,
+    )
+    const optionsCloned = cloneDeepUnref(
+      toValueDeep(options) as MaybeRefDeep<InvalidateOptions>,
+    )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/queryClient.ts` around lines 216 - 221, The code
currently passes potential getter functions directly into cloneDeepUnref (e.g.,
when building filtersCloned and optionsCloned), but
cloneDeepUnref(unrefGetters=false) won't invoke root-level getters so function
objects slip through; fix by first resolving any getters with toValueDeep on the
original inputs (filters and options) and then pass the resolved values into
cloneDeepUnref (i.e., replace the direct cloneDeepUnref(filters as
MaybeRefDeep<...>) and cloneDeepUnref(options as MaybeRefDeep<...>) flows with
toValueDeep(...) followed by cloneDeepUnref(...) so root-level getter functions
are invoked before cloning).

Comment on lines +25 to +27
>]: Property extends 'enabled'
? () => Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>>
: QueryObserverOptions<
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "1) Inspect Enabled/QueryObserverOptions definitions in query-core"
rg -n --type=ts -C3 'export type Enabled|enabled\??:' packages/query-core

echo
echo "2) Inspect vue-query QueryOptions enabled mapping"
rg -n --type=ts -C3 "Property extends 'enabled'" packages/vue-query/src/queryOptions.ts

echo
echo "3) Find boolean-enabled queryOptions call patterns in vue-query tests"
rg -n --type=ts -C2 'enabled:\s*(true|false)' packages/vue-query/src/__tests__

Repository: TanStack/query

Length of output: 22769


🏁 Script executed:

# Get the full Enabled type definition from query-core
sed -n '113,125p' packages/query-core/src/types.ts

echo "---"

# Check the full QueryOptions field definition in query-core
sed -n '326,330p' packages/query-core/src/types.ts

echo "---"

# View the full QueryOptions mapped type in vue-query to understand the structure
sed -n '12,40p' packages/vue-query/src/queryOptions.ts

Repository: TanStack/query

Length of output: 1291


enabled is now getter-only; plain enabled values are no longer accepted.

The QueryOptions mapped type restricts enabled to () => Enabled<...> (function-only), but the core library's Enabled type is defined as boolean | ((query) => boolean). This breaks existing code using enabled: true or enabled: false.

Proposed type fix
   >]: Property extends 'enabled'
-    ? () => Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>>
+    ?
+        | Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>>
+        | (() => Enabled<
+            TQueryFnData,
+            TError,
+            TQueryData,
+            DeepUnwrapRef<TQueryKey>
+          >)
     : QueryObserverOptions<
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/queryOptions.ts` around lines 25 - 27, The mapped type
for QueryOptions incorrectly forces the 'enabled' property to be a getter only;
change the mapping for Property extends 'enabled' in QueryOptions so it accepts
the core library's Enabled type (boolean | (query)=>boolean) rather than only a
no-arg function. Locate the mapped type in QueryOptions (the clause currently
returning "() => Enabled<...>") and replace it with the correct
Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>> type (or a
union of boolean and the predicate signature) so that plain true/false and
predicate functions are both accepted; ensure QueryObserverOptions usage remains
unchanged.

Comment on lines +113 to +114
export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {
return isFunction(source) ? source() : cloneDeepUnref(source)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Getter branch skips deep unref/clone normalization.

When source is a function, toValueDeep returns source() directly, so nested refs/getters are not normalized like they are for non-function input. This can produce different runtime behavior for equivalent inputs.

💡 Proposed fix
 export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {
-  return isFunction(source) ? source() : cloneDeepUnref(source)
+  const value = isFunction(source) ? source() : source
+  return cloneDeepUnref(value as MaybeRefDeep<T>)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {
return isFunction(source) ? source() : cloneDeepUnref(source)
export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {
const value = isFunction(source) ? source() : source
return cloneDeepUnref(value as MaybeRefDeep<T>)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/utils.ts` around lines 113 - 114, toValueDeep
currently returns source() directly when source is a function, skipping deep
unref/clone normalization and causing inconsistent behavior; modify toValueDeep
so it always passes the resolved value through cloneDeepUnref (e.g., compute
const resolved = isFunction(source) ? source() : source and return
cloneDeepUnref(resolved)) so both function and non-function inputs get identical
deep-unref/clone treatment; keep references to toValueDeep, isFunction,
cloneDeepUnref and MaybeRefDeep in the change.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 11, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 0649ccb

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.99 KB (0%)
react minimal 9.02 KB (0%)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/vue-query/src/queryClient.ts (1)

286-310: ⚠️ Potential issue | 🔴 Critical

fetchQuery overload accepts getter but implementation doesn't invoke it.

The public overload accepts (() => FetchQueryOptions<...>), but the implementation only accepts MaybeRefDeep<FetchQueryOptions<...>>. When a getter function is passed, cloneDeepUnref will not invoke it—the function object itself gets passed to super.fetchQuery(), causing a runtime error.

Replace cloneDeepUnref(options) with toValueDeep(options) to properly handle both getter functions and reactive references. The toValueDeep utility already handles this pattern correctly by checking isFunction(source) first before falling back to cloneDeepUnref.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/queryClient.ts` around lines 286 - 310, The fetchQuery
implementation currently passes cloneDeepUnref(options) to super.fetchQuery
which doesn't invoke getter overloads; change the call in the fetchQuery method
to use toValueDeep(options) so functions (getter overloads) and refs are
resolved before forwarding to super.fetchQuery; ensure you update any imports to
include toValueDeep and keep the existing overload signatures (MaybeRefDeep and
FetchQueryOptions) unchanged.
🧹 Nitpick comments (1)
packages/vue-query/src/index.ts (1)

8-9: Consider combining exports from ./queryOptions.

Both the runtime queryOptions function and the QueryOptions type are exported from the same module. These can be combined into a single export statement.

♻️ Optional consolidation
-export { queryOptions } from './queryOptions'
-export { type QueryOptions } from './queryOptions'
+export { queryOptions, type QueryOptions } from './queryOptions'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/index.ts` around lines 8 - 9, The exports in index.ts
export both the runtime symbol queryOptions and the type QueryOptions
separately; combine them into a single consolidated export from './queryOptions'
by exporting queryOptions and type QueryOptions together (reference symbols:
queryOptions, QueryOptions, and module './queryOptions') so the file uses one
export statement instead of two.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/vue-query/src/queryClient.ts`:
- Around line 286-310: The fetchQuery implementation currently passes
cloneDeepUnref(options) to super.fetchQuery which doesn't invoke getter
overloads; change the call in the fetchQuery method to use toValueDeep(options)
so functions (getter overloads) and refs are resolved before forwarding to
super.fetchQuery; ensure you update any imports to include toValueDeep and keep
the existing overload signatures (MaybeRefDeep and FetchQueryOptions) unchanged.

---

Nitpick comments:
In `@packages/vue-query/src/index.ts`:
- Around line 8-9: The exports in index.ts export both the runtime symbol
queryOptions and the type QueryOptions separately; combine them into a single
consolidated export from './queryOptions' by exporting queryOptions and type
QueryOptions together (reference symbols: queryOptions, QueryOptions, and module
'./queryOptions') so the file uses one export statement instead of two.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 61d62eb3-86e6-47db-9747-92d7e1d567e7

📥 Commits

Reviewing files that changed from the base of the PR and between 47e4c6b and 0649ccb.

📒 Files selected for processing (9)
  • .changeset/three-pillows-enter.md
  • packages/vue-query/src/__tests__/queryOptions.test-d.ts
  • packages/vue-query/src/__tests__/queryOptions.test.ts
  • packages/vue-query/src/__tests__/useQueries.test-d.ts
  • packages/vue-query/src/index.ts
  • packages/vue-query/src/queryClient.ts
  • packages/vue-query/src/queryOptions.ts
  • packages/vue-query/src/types.ts
  • packages/vue-query/src/utils.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/vue-query/src/tests/queryOptions.test.ts
  • packages/vue-query/src/types.ts
  • packages/vue-query/src/tests/useQueries.test-d.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/vue-query/src/utils.ts
  • packages/vue-query/src/tests/queryOptions.test-d.ts

@DamianOsipiuk DamianOsipiuk merged commit 29e80d9 into main Apr 11, 2026
8 checks passed
@DamianOsipiuk DamianOsipiuk deleted the do/fix-query-options-types branch April 11, 2026 16:01
@github-actions github-actions bot mentioned this pull request Apr 11, 2026
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.

[vue-query] Type error: queryOptions return type only contains the queryKey and initialData properties

1 participant