Conversation
`UseMutationReturnType` uses `MutationResult` as the default for its `TResult` parameter, but the alias was not exported. Projects that emit declarations could not name the inferred return type of a `useMutation` wrapper and failed with TS2883. Export it from the package root. Fixes TanStack#11769 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: TanStack/query/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe ChangesVue MutationResult export
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change makes a type available to consumers without changing runtime behavior. No concrete merge-blocking risk is evident. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The existing mutation result type becomes publicly nameable without changing its shape or adding executable functionality. No material security risk is introduced by the examined change. Retained concerns Security review detailsSecurity Blast Radius
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
🎯 Changes
Export MutationResult from @tanstack/vue-query so TypeScript can name the return type of exported useMutation wrappers when generating declarations. This fixes #11769: I reproduced TS2883 with version 5.104.0 in ESM and CommonJS projects using TypeScript 6.0.3, confirmed it is resolved with the fixed build, and ran the package tests, type tests, and lint. I used Claude Code to help prepare and test this change.
What the change does
UseMutationReturnType uses MutationResult as a default type argument, but MutationResult is currently local to useMutation.ts and absent from the package entry point. The fix exports that existing type from its source file and re-exports it from @tanstack/vue-query. That lets TypeScript write the type name into generated declarations for a wrapper such as export function useSave() { return useMutation(...) }.
The existing type describes the mutation observer result without mutate and reset; Vue Query's return type adds its own versions of those members. The change makes that type name accessible without changing mutation behavior or adding a runtime export. Keeping the named type also avoids a likely pnpm resolution problem from inlining its definition.
✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit
MutationResulttype from Vue Query, so you can name inferreduseMutationreturn types in declaration files.