What is the return type of useQuery?
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>>'."
2 Replies
correct-apricot•4y ago
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
queryFnstormy-goldOP•4y ago
that is true it doesnt have to be typed but I have a rule to type every function return type