#Good way to get a return type?

5 messages · Page 1 of 1 (latest)

lapis kestrel
#

What's the best way in typescript to grab the return type from a query with Convex 17+?

drowsy wasp
#

Are you using the return type in a convex function or in the client (react)?

hoary star
#

You can type import the query and get the ReturnType<typeof yourQuery>, or more convenient maybe api.foo.bar["_returnType"]

light cave
#

Where yourQuery can be api.foo.bar, right Tom? Or just referencing the function directly if it’s server-side?

hoary star
#

Ah sorry unclear example, yeah api.directoryName.fileName.yourQuery["_returnType"]. Both of these work client- or server-side, but it's important to use a type import instead of a normal import if you use the first method.