#What is the return type of useQuery?

2 messages · Page 1 of 1 (latest)

ebon snow
#

I have a composable that runs useQuery and specifies a return type of: UseQueryReturnType<TypedMaterial[], unknown>
I get the error "TS2322: Type 'UseQueryReturnType<TypedMaterial[], unknown>' is not assignable to type 'UseQueryReturnType<TypedMaterial[], unknown, QueryObserverResult<TypedMaterial[], unknown>>"

When I change the return type to UseQueryReturnType<TypedMaterial[], unknown, QueryObserverResult<TypedMaterial[], unknown>>
I get the error "TS2322: Type 'UseQueryReturnType<TypedMaterial[], unknown>' is not assignable to type 'UseQueryReturnType<TypedMaterial[], unknown, QueryObserverResult<TypedMaterial[], unknown>>'."

fresh falcon
#

You do not have to type it manually. Typescript should be able to automatically infer the return type.
The only thing you need to type is probably your queryFn