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
However, in actual usage, if the select option is not provided, it cannot infer the type of TData. The data type is always unknown, so I have to pass the select option every time, for example:
interfaceUser{
id: number
name: string}constfetchUser=(id: number)=>Promise.resolve<User>({ id,name: 'user'})constuserQueryOptions=(id: number)=>queryOptions({queryKey: ['/api/users',id],queryFn: fetchUser,})// The type of data is unknownconst{ data }=useQuery({
...userQueryOptions(1),})// The type of data can be correctly inferred, data is User or undefined const{ data }=useQuery({
...userQueryOptions(2),select: data=>data,})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Below is my implementation based on the overload definitions:
However, in actual usage, if the select option is not provided, it cannot infer the type of TData. The data type is always unknown, so I have to pass the select option every time, for example:
Beta Was this translation helpful? Give feedback.
All reactions