[vue-query]: UseMutationReturnType default names unexported MutationResult (TS2883) 🤖🤖🤖
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
Start with the vue-query adapter declarations for UseMutationReturnType and useMutation, using src/useExampleMutation.ts and the provided vue-tsc --build command as the reproduction. Trace how the published type references MutationResult, then verify that declaration emit succeeds without a private-type diagnostic or an unexported type reference.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
@tanstack/vue-query 5.104.0 publishes UseMutationReturnType with a default type argument that names MutationResult. MutationResult is not exported. A project that emits declarations (composite: true, which implies declaration) cannot name the inferred return type of an exported wrapper around useMutation.
TypeScript reports:
TS2883: The inferred type of 'useExampleMutation' cannot be named without a reference to 'MutationResult' from '@tanstack/vue-query/build/modern/useMutation'. This is likely not portable. A type annotation is necessary.
@ts-expect-error on the export suppresses TS2883 and is then reported as unused (TS2578). The diagnostic is produced during declaration emit, after TypeScript decides whether the directive was used. @ts-ignore is not a substitute we can use.
5.91.2 still declares the private alias, but the published .d.ts re-exports the function with export { type UseMutationReturnType, useMutation }. That form typechecks. 5.104.0 uses export type UseMutationReturnType<..., TResult = MutationResult<...>> and export declare function useMutation, and declaration emit then has to name MutationResult.
Related, and not the same report:
- #6318 (closed) was an earlier "not portable" failure from tsup renaming exports.
- #11038 (closed) was
TS2883undernodenextfromexperimentalDts. - #11042 (open) is the same class of bug for
queryOptions(), not foruseMutation.
Your minimal, reproducible example
No hosted sandbox. vue-tsc --build against a composite project is the reproduction. The three files below are complete.
package.json
{
"private": true,
"type": "module",
"dependencies": {
"@tanstack/vue-query": "5.104.0",
"vue": "3.5.43"
},
"devDependencies": {
"typescript": "6.0.3",
"vue-tsc": "3.3.11"
}
}
tsconfig.json
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"target": "esnext",
"skipLibCheck": true
},
"include": ["src"]
}
src/useExampleMutation.ts
import { useMutation } from '@tanstack/vue-query'
export const useExampleMutation = () => {
return useMutation({
mutationFn: async () => 'ok',
})
}
Steps to reproduce
- Install the three files above.
- Run
pnpm exec vue-tsc --build --noEmit --force. - See
TS2883onuseExampleMutation. - Repeat with
@tanstack/vue-query5.91.2. The same command exits 0.
Expected behavior
An exported wrapper around useMutation should typecheck under composite / declaration emit without naming a private type. MutationResult should be exported, or it should not appear as a default type argument on the public UseMutationReturnType.
How often does this bug happen?
Every time
Platform
- OS: macOS
- Browser: not applicable (vue-tsc)
- Version: TypeScript 6.0.3, vue-tsc 3.3.11, Vue 3.5.43
Tanstack Query adapter
vue-query
TanStack Query version
5.104.0 (does not reproduce on 5.91.2)
TypeScript version
6.0.3
Additional context
Annotating the wrapper as UseMutationReturnType<TData, TError, TVariables, unknown> is not assignable to the value useMutation returns, because that value is instantiated with the private fifth type argument. The annotation only typechecks if the consumer copies MutationResult (DistributiveOmit<MutationObserverResult<...>, 'mutate' | 'reset'>). That copy has to stay in sync with an unexported alias.
- 主要语言
- TypeScript
- 星标
- 50.4k
- 派生
- 4.2k
- 平均合并
- 7 小时 29 分钟
- 30 天内合并 PR
- 393
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/query 的其他 Issue
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
TanStack/query#11358 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
solid-query: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)可能已有人在做 @MaNaN1803 于 75 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
TanStack/query#11106 · 1 条评论 ·
维护者通常 1 天内回复
-
restoreQueries and persisterGc throw on malformed persisted entries可能已有人在做 @VGontier-cmd 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 72/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
setQueryData: NoInfer loses discriminated-union members when spreading a narrowed updater value可能已有人在做 @iosayin 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
Comfy-Org/ComfyUI_frontend#20346 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
decentralized-identity/didwebvh-ts#203 ·
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 2/5 1-3 小时 新手友好度 65/100
lingdojo/kana-dojo#31791 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
Telegram webhook: line breaks lost since switch to rich messages可能已有人在做 @Kshot3000 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
github_actions security
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复