vue-query: `queryOptions()`'s real return type is unexported; the public name with the same identifier points at a different, legacy type · Issue #11042 · TanStack/query · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vue-query: queryOptions()'s real return type is unexported; the public name with the same identifier points at a different, legacy type #11042
Since the 5.98.0 rewrite ("fix(vue-query): fix type of queryOptions to allow plain properties or getters"), queryOptions() is typed against a newQueryOptions-based shape. In the published rollup declaration file (build/modern/_tsup-dts-rollup.d.ts) this shape exists as UndefinedInitialQueryOptions_alias_1 / DefinedInitialQueryOptions_alias_1 — but:
_alias_1 is not exported from the package root (build/modern/index.d.ts).
The public names UndefinedInitialQueryOptions / DefinedInitialQueryOptions are re-exported from the root, but they still point at the old, UseQueryOptions-based, MaybeRef<...>-union type. Two genuinely different types share one exported name; only the wrong one is reachable.
Supporting types referenced by the new signature are unexported too: vue-query's ShallowOption, its local MaybeRefOrGetter alias, and query-core's QueryBehavior, RetryValue, RetryDelayValue, plus a non-exported unique symbol (dataTagErrorSymbol).
Any library that exports a function returning queryOptions(...) with an inferred return type — the exact pattern @kubb/plugin-vue-query generates for every endpoint — hits one of two consequences when its declarations are emitted:
Hard declaration-emit errors (TS2527/TS2883) — reproduced here with both tsdown/rolldown-plugin-dts and plain tsc.
Silently WRONG declarations — the natural fix for (1) is to annotate the return type with the public UndefinedInitialQueryOptions. That compiles with zero errors, but it is the wrong type: a consumer spreading the factory's result into another queryOptions() call to add select fails to type-check, and the DataTag on queryKey is lost.
Both are reproduced below, from the same root cause: the name collision.
The same-name legacy export is especially risky because declaration generation can succeed while DataTag information is lost. A package-level declaration fixture could export an inferred factory result, consume it from another fixture package, spread it into queryOptions() with select, and assert the selected result type across both tsc and the rollup declaration path.
It looks like queryOptions() returns types based on the UndefinedInitialQueryOptions / DefinedInitialQueryOptions declarations in queryOptions.ts, while the package root exports same-named types from useQuery.ts. That seems to make the actual queryOptions() return types hard to name from the published package surface
I'd like to work on this
My plan is to add a consumer-style declaration emit regression test, make the queryOptions() return types nameable from the package root, and verify that DataTag still survives when the emitted result is consumed and spread back into queryOptions() with select
Activity
DesselBane commentedon Jul 10, 2026
Might be related to #10904
hiSandog commentedon Jul 11, 2026
The same-name legacy export is especially risky because declaration generation can succeed while
DataTaginformation is lost. A package-level declaration fixture could export an inferred factory result, consume it from another fixture package, spread it intoqueryOptions()withselect, and assert the selected result type across bothtscand the rollup declaration path.zaewc commentedon Jul 12, 2026
It looks like
queryOptions()returns types based on theUndefinedInitialQueryOptions/DefinedInitialQueryOptionsdeclarations inqueryOptions.ts, while the package root exports same-named types fromuseQuery.ts. That seems to make the actualqueryOptions()return types hard to name from the published package surfaceI'd like to work on this
My plan is to add a consumer-style declaration emit regression test, make the
queryOptions()return types nameable from the package root, and verify thatDataTagstill survives when the emitted result is consumed and spread back intoqueryOptions()withselect