Is there a way to save the generated response Type from a query?
I see that when you hover over the type for the response of a query, you can see what data will be returned. Is there a way to extract, or save that Type somehow, so I can use it elsewhere?
7 Replies
ReturnType<typeof query.run>
?
Yes thank you this is perfect!!
Weird for some reason trying this now, it does not work?
Giving a type error, something about not satisifying the contraint
provides no match for the signature '(...args: any): any'
Can you share the code? It's probably not a function that's being passed to ReturnType
sure:
leave
.prepare()
out of the variable
and call it like this getItemOrder.prepare()
typeof
basically "yanks" a runtime thing into the type level above it (that's how I think about it)
so if you call typeof on a function you wrap it in returntype to get the return of the function --- however in your case above you're calling returntype on a result, not a function
so you don't need it, just leave it outhmm
this sort of works but gives me the actually execution as the type, not the result really
Screenshot of hover?