Skip to content

fix(vue-query): export MutationResult type - #11796

Open
KirbyBT wants to merge 1 commit into
TanStack:mainfrom
KirbyBT:fix/vue-query-export-mutation-result
Open

KirbyBT wants to merge 1 commit into
TanStack:mainfrom
KirbyBT:fix/vue-query-export-mutation-result

Conversation

@KirbyBT

@KirbyBT KirbyBT commented Oct 1, 2026 •

Copy link
Copy Markdown

🎯 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

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features
    • Exported the MutationResult type from Vue Query, so you can name inferred useMutation return types in declaration files.

`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>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f1141da6-25f4-4010-a930-e59d324e0999

📥 Commits

Reviewing files that changed from the base of the PR and between 3df6cb9 and 05c60f1.

📒 Files selected for processing (3)
  • .changeset/export-vue-mutation-result.md
  • packages/vue-query/src/index.ts
  • packages/vue-query/src/useMutation.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The MutationResult type is now exported from @tanstack/vue-query. A patch changeset records the export.

Changes

Vue MutationResult export

Layer / File(s) Summary
Public type export
packages/vue-query/src/useMutation.ts, packages/vue-query/src/index.ts, .changeset/export-vue-mutation-result.md
MutationResult is exported from useMutation.ts and re-exported from the package entry point. The changeset records a patch release.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: sukvvon

Merge Risk: ⚪ Minimal · up to 05c60

This change makes a type available to consumers without changing runtime behavior. No concrete merge-blocking risk is evident.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 05c60

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The incremental exposure is limited to compile-time type visibility for Vue Query consumers. The added exports do not create an executable attack path or grant additional mutation authority.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #11769 requires exported wrappers around useMutation to emit declarations without naming the private MutationResult type. The PR exports MutationResult from `packages/vue-query/src/useMuta…
Out of Scope Changes check ✅ Passed The changes only alter type visibility and the package type re-export for the useMutation declaration issue in #11769. The changeset documents the same public type export. No unrelated behavior, run…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Title check ✅ Passed The title clearly and concisely identifies the primary change: exporting the MutationResult type from Vue Query.
Description check ✅ Passed The description follows the required template, explains the motivation and implementation, documents testing, acknowledges AI assistance, and includes the required changeset checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vue-query]: UseMutationReturnType default names unexported MutationResult (TS2883) 🤖🤖🤖

1 participant