Skip to content

useMutation callbacks context type depends on options object sorting #8988

Open
@alexw-at

Description

@alexw-at

Describe the bug

The type of context in the useMutation callbacks depends on the sorting of the options object.

Your minimal, reproducible example

https://codesandbox.io/p/devbox/usemutationcontext-qsnk89

Steps to reproduce

  1. Open minimal reproduction
  2. Open file src/index.tsx or run tsc --noemit
  3. Type of context in callbacks depends options object sorting
  4. first useMutation works as intended, second useMutation has type errors

Expected behavior

The type of context in useMutation callbacks should always be the same and not depend on the options object sorting.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Seems to be a types only bug. Has no effect on runtime values.

Tanstack Query adapter

react-query

TanStack Query version

5.72.2

TypeScript version

5.8.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions