vue-query: `queryOptions()`'s real return type is unexported; the public name with the same identifier points at a different, legacy type
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- typescript
调研方向
先从 build/modern/_tsup-dts-rollup.d.ts 中已发布的声明和 build/modern/index.d.ts 中的导出开始,然后阅读 queryOptions 的实现以及复现仓库的 README.md。运行列出的 tsdown 和 tsc 复现;当声明能够在没有 TS2527/TS2883 的情况下生成,并且下游的 select 组合保留正确的 query options 和 DataTag 类型时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Since the 5.98.0 rewrite ("fix(vue-query): fix type of queryOptions to allow plain properties or getters"), queryOptions() is typed against a new QueryOptions-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_1is not exported from the package root (build/modern/index.d.ts).- The public names
UndefinedInitialQueryOptions/DefinedInitialQueryOptionsare 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 localMaybeRefOrGetteralias, and query-core'sQueryBehavior,RetryValue,RetryDelayValue, plus a non-exportedunique 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 bothtsdown/rolldown-plugin-dtsand plaintsc. - 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 anotherqueryOptions()call to addselectfails to type-check, and theDataTagonqueryKeyis lost.
Both are reproduced below, from the same root cause: the name collision.
Your minimal, reproducible example
https://github.com/DesselBane/repro-vue-query-query-options
Steps to reproduce
See repo README.md
Expected behavior
No TS2527 error and/or correct type exported so that downstream select works
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
| Package | Version |
|---|---|
@tanstack/vue-query |
5.101.2 (also confirmed broken at 5.98.0; 5.97.0 is clean — see Regression window) |
@tanstack/query-core |
5.101.2 (transitive) |
typescript |
6.0.3 |
vue |
3.5.31 |
tsdown |
0.21.4 ([email protected], [email protected]) |
| Node | v24.0.0 |
| OS | Windows 11 |
Tanstack Query adapter
vue-query
TanStack Query version
5.98.0 (and 5.101.2)
TypeScript version
6.0.3
Additional context
Diagnosis and reproduction were created with the help of CLAUDE. I checked the repo and as far as I can tell this is all correct.
- 主要语言
- TypeScript
- 星标
- 50.6k
- 派生
- 4.2k
- 平均合并
- 9 小时 50 分钟
- 30 天内合并 PR
- 310
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/query 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
TanStack/query#12466 · 1 条评论 ·
维护者通常 1 天内回复
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)可能重新可做 @LeonxLJX 于 77 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
TanStack/query#11358 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
select that throws for placeholderData brings back the selection of data removed by resetQueries可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 56/100
维护者通常 1 天内回复
-
Render loop since v5.105.2 when placeholderData, or its select result, is not referentially stable未关闭
难度 4/5 3-5 天 新手友好度 54/100
维护者通常 1 天内回复
-
useQueries: stable combine returns a stale result when a query updates before setQueries runs可能已有人在做 @sakaintp 于 1 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 62/100
TanStack/query#12626 · 2 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
fb55/htmlparser2#2579 ·
维护者通常 1 天内回复
-
bug good first issue needs-review
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
documentation public
难度 1/5 1-3 小时 新手友好度 68/100
midnightntwrk/umbradb#65 ·
维护者通常 2 天内回复
-
area/channels kind/bug priority/medium
难度 2/5 1-3 小时 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 条评论 ·
维护者通常 1 天内回复
-
needs verification
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 13 天内回复