How to properly type function arguments for procedures?
I'm using tRPC 10 with
trpc/react-query
I'm trying to understand how to create a function that receives a procedure and it's input as arguments, so that I can then use that procedure reference to call useQuery and getQueryKey within the function:
I'm trying to create a generic useSubscription hook. I want the useSubscription function signature to take in the procedure and it's input, but properly typed.
I've tried approaches like:
But this fails for a number of reasons. The RouterInputs lookup fails because it only supports the top-level routes in my router. Can I access a flat tree of types for inputs?
getQueryKey also doesn't like taking in TProcedure when its typed as AnyQueryProcedure, the type errors suggest that it wants a decorated version, but I can't figure out how to type it properly.
Any help would be greatly appreciated.0 Replies