Skip to content

Query callback function typing is broken in latest v4 release #9240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cietho opened this issue Jun 3, 2025 · 2 comments · May be fixed by #9242
Open

Query callback function typing is broken in latest v4 release #9240

cietho opened this issue Jun 3, 2025 · 2 comments · May be fixed by #9242
Assignees

Comments

@cietho
Copy link

cietho commented Jun 3, 2025

Describe the bug

The latest release for @tanstack/react-query v4 breaks the typing of query callback functions onSuccess and onSettled. Instead of infering the typing from the queryFn result, the type is any.

Your minimal, reproducible example

cietho@c8e8ced (Basically you can just checkout the tagged v4.39.1 branch and try to build the typescript examples)

Steps to reproduce

  1. Install @tanstack/react-query@4.39.1
  2. Write a query using TypeScript
  3. Type the queryFn response
  4. Try to access the data returned by queryFn in a typesafe way

Expected behavior

As a developer, I expected the data to be typed as the return type of the queryFn but I am seeing data being typed as any.

How often does this bug happen?

None

Screenshots or Videos

Image

Platform

  • macOS

Tanstack Query adapter

react-query

TanStack Query version

v4.39.1

TypeScript version

v4.8.3 and v5.8.3

Additional context

No response

@cietho cietho changed the title Query callback function typing is broken Query callback function typing is broken in latest v4 release Jun 3, 2025
@TkDodo
Copy link
Collaborator

TkDodo commented Jun 3, 2025

@manudeli can you take a look please

@manudeli manudeli self-assigned this Jun 3, 2025
@manudeli manudeli linked a pull request Jun 3, 2025 that will close this issue
@manudeli
Copy link
Collaborator

manudeli commented Jun 4, 2025

@manudeli can you take a look please

@TkDodo, I fixed this in #9242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants