We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
v5.61.0 breaks queryKey inference, I think as a result of this change 3fa4b7c
import { queryOptions as queryOptions1 } from "react-query-5-60-6"; import { queryOptions as queryOptions2 } from "react-query-5-61-0"; queryOptions1({ queryKey: ["test"] as const, queryFn: () => fetch("https://example.com"), }).queryKey; // ^? (property) queryKey: readonly ["test"] & { [dataTag... queryOptions2({ queryKey: ["test"] as const, queryFn: () => fetch("https://example.com"), }).queryKey; // ^? (property) queryKey: QueryKey & { [dataTag...
We use queryOptions to create query factories and have invalidation helpers that rely on the queryKey type.
Failing test: a77db3e
https://stackblitz.com/edit/rq-querykey-infer?file=index.ts&view=editor
/
queryKey should be inferred when using queryOptions
queryKey
queryOptions
Every time
No response
macOS Chrome
react-query
5.61.0
5.5.4
The text was updated successfully, but these errors were encountered:
Thanks, I think I broke this with:
If you want, you can take a stab at fixing it while retaining the functionality of that PR ?
Sorry, something went wrong.
Is the goal of #8317 to avoid having to specify all the generics?
This works on v5.60.6 prior to #8317:
function somethingWithQueryOptions< TQueryFnData extends unknown, TError, TData, TQueryKey extends QueryKey, >(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>) { return options.queryKey } const options = queryOptions({ queryKey: ['key'] as const, queryFn: () => Promise.resolve({ a: 1 }), select: (v) => v.a, }) somethingWithQueryOptions(options)
or
function somethingWithQueryOptions<TError, TQueryKey extends QueryKey>( options: UseQueryOptions<number, TError, number, TQueryKey>, ) { return options.queryKey } const options = queryOptions({ queryKey: ['key'], queryFn: () => Promise.resolve(1), }) somethingWithQueryOptions(options)
This look like it will be fixed by: #8394
No branches or pull requests
Describe the bug
v5.61.0 breaks queryKey inference, I think as a result of this change 3fa4b7c
Example
We use queryOptions to create query factories and have invalidation helpers that rely on the queryKey type.
Failing test: a77db3e
Your minimal, reproducible example
https://stackblitz.com/edit/rq-querykey-infer?file=index.ts&view=editor
Steps to reproduce
/
Expected behavior
queryKey
should be inferred when usingqueryOptions
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
macOS
Chrome
Tanstack Query adapter
react-query
TanStack Query version
5.61.0
TypeScript version
5.5.4
Additional context
No response
The text was updated successfully, but these errors were encountered: