Skip to content

fix(lit-query): propagate mutation state generics - #11355

Open
Osraka wants to merge 1 commit into
TanStack:mainfrom
Osraka:osraka/fix-lit-mutation-state-generics
Open

fix(lit-query): propagate mutation state generics#11355
Osraka wants to merge 1 commit into
TanStack:mainfrom
Osraka:osraka/fix-lit-mutation-state-generics

Conversation

@Osraka

@Osraka Osraka commented Sep 1, 2026

Copy link
Copy Markdown

🎯 Changes

@tanstack/lit-query did not receive the useMutationState generic inference added to the other framework adapters in #10373. As a result, a selector with an explicitly typed MutationState<TData, TError, TVariables> still saw Mutation<unknown, Error, unknown, unknown>.

This PR:

  • derives the selector's Mutation type from the selected MutationState result
  • adds a focused compile-time regression test
  • keeps runtime filtering/subscription behavior and scalar selector inference unchanged

The regression test fails on current main and passes with this change.

✅ 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 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

  • Bug Fixes

    • Improved TypeScript type inference for useMutationState.
    • Generic mutation types now flow correctly into the select callback, providing accurate types for mutation data, errors, and variables.
  • Tests

    • Added type-level coverage to verify generic mutation types are correctly propagated.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 6b4187b3-a2ac-4277-93fd-f64003eda4ad

📥 Commits

Reviewing files that changed from the base of the PR and between a85d4f1 and 185d545.

📒 Files selected for processing (3)
  • .changeset/lit-mutation-state-generics.md
  • packages/lit-query/src/tests/mutation-state-types.test.ts
  • packages/lit-query/src/useMutationState.ts

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


📝 Walkthrough

Walkthrough

useMutationState now propagates mutation generic parameters to the select callback. The change updates type inference and controller wiring, adds a type-level test, and records a patch release for @tanstack/lit-query.

Changes

Lit mutation state generic propagation

Layer / File(s) Summary
Mutation type propagation
packages/lit-query/src/useMutationState.ts
useMutationState infers the mutation type from MutationState, passes it through MutationStateOptions and MutationStateController, and supplies it to the select callback.
Type-level validation and release metadata
packages/lit-query/src/tests/mutation-state-types.test.ts, .changeset/lit-mutation-state-generics.md
The type test verifies the propagated Mutation generics. The changeset records a patch release.

|

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

Merge Risk: ⚪ Minimal · up to 185d5

This change improves mutation-state generic inference while preserving existing runtime cache, filtering, subscription, and callback behavior; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: propagating mutation state generics in @tanstack/lit-query.
Description check ✅ Passed The description is complete and relevant. It explains the issue, implementation, regression test, runtime impact, checklist completion, and included changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant