You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Install @tanstack/react-query@4.39.1
Write a query using TypeScript
Type the queryFn response
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
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
The text was updated successfully, but these errors were encountered:
cietho
changed the title
Query callback function typing is broken
Query callback function typing is broken in latest v4 release
Jun 3, 2025
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
The latest release for @tanstack/react-query v4 breaks the typing of query callback functions
onSuccess
andonSettled
. Instead of infering the typing from thequeryFn
result, the type isany
.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
@tanstack/react-query@4.39.1
queryFn
responsedata
returned byqueryFn
in a typesafe wayExpected behavior
As a developer, I expected the
data
to be typed as the return type of thequeryFn
but I am seeingdata
being typed asany
.How often does this bug happen?
None
Screenshots or Videos
Platform
Tanstack Query adapter
react-query
TanStack Query version
v4.39.1
TypeScript version
v4.8.3 and v5.8.3
Additional context
No response
The text was updated successfully, but these errors were encountered: