-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe the bug
We recently updated @tanstack/react-query to version 5.90.11 and it introduced type errors, we believe related to the change in #8683
We have a map from an enum value to an interface so that we can have generic data loaders with the correct data type returned (simplified example in the attached TS Playground link) and then use that elsewhere to make other functions generic.
We are now getting this TS error:
Argument of type 'NoInfer<DataTypeToEntity[DT]>' is not assignable to parameter of type 'DataTypeToEntity[DT]'.
Type '[DataTypeToEntity[DT]]' is not assignable to type 'DataTypeToEntity'.
I created a very simple reproduction of the issue with NoInfer that also shows the issue not happening with the built-in NoInfer from TS 5.4 - https://www.typescriptlang.org/play/?#code/KYOwrgtgBAIghgFzgFQJ4AdhQN4CgpQCCAxsQPZggJQC8UA5HKRVfQDT5QAKATmQCZhi1OvXR9Bw+rgC+uXAEsqwHgDMmWEuUrU8BEHAjAAXFADOCHkoDmAblnylCFeuJZeAobs7l+J85Y29nK4wAAe6GQ81AgYWPBIaJjIZACiVAqxtDicANoJKHEAdFosCAC6pqU69gT5iIWYRR6SFaYtXg64APTdUMgAFgpmUMNQCANYsZhQqnzQAEoAirjTWAByZACSIKoqAEwAPMgAfNm5yOUXUOHOIPwjcCCoUAD8UAAMUKYgwABuKnK9lw5BAFnGwHBdEOMGQNzCdwesAaSWAJwAFPwUXFTLC2FAsUhTJsdnseDDsck0hlYvlLicAJS0M56KCg8FwMxmBTWX78XGU4ApdIITKoOnlbKEuDBeTsmKQhD7bIwuG3UBIgqojHS1G45D46XE7a7A4UxJxYU08Ww8qM5k5AjyqCc7m84D85EWqkisUSqUNYJAA
Also doesn't seem to happen with a simpler type NoInfer<T> = [T] extends [T] ? T : never approach.
I know this is very much an edge-case but I'm struggling to find a workaround other than casting or passing generics into useQuery, neither of which are ideal.
Your minimal, reproducible example
Steps to reproduce
The error is shown at the bottom of the TS Playground link, where we attempt to assign data to a type that should match fine.
Expected behavior
The type should be fine because NoInfer<SomeType> should be able to be assigned to SomeType.
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
@tanstack/react-query: v5.90.11
TypeScript: 5.7.2 (our codebase) / 5.9.3 (TS Playground)
Tanstack Query adapter
None
TanStack Query version
5.90.11
TypeScript version
5.9.3
Additional context
No response