[vue-query]: UseMutationReturnType default names unexported MutationResult (TS2883) 🤖🤖🤖
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- frontend
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 50.4k
- Fork
- 4.2k
- Merge medio
- 7h 29m
- PR unite (30g)
- 393
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/query#11358 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
solid-query: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)Forse già presa @MaNaN1803 l’ha presa 75 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/query#11106 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
restoreQueries and persisterGc throw on malformed persisted entriesForse già presa @VGontier-cmd l’ha presa oggi. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
setQueryData: NoInfer loses discriminated-union members when spreading a narrowed updater valueForse già presa @iosayin l’ha presa 2 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/query
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Comfy-Org/ComfyUI_frontend#20346 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
decentralized-identity/didwebvh-ts#203 ·
I maintainer di solito rispondono entro 1 giorno
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
lingdojo/kana-dojo#31791 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Telegram webhook: line breaks lost since switch to rich messagesForse già presa @Kshot3000 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
github_actions security
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno