How do I pass a Generic to a trpc query procedure?
I want to to something like this:
This is how you pass a generic to a function, as we know. I wanted to do it in a procedure. Right now I have a procedure:
3 Replies
You’re usually best to go with a Router Factory for this type of situation, so you produce two separate routers but with a different Parser provided and the types get inferred nicely
DEV Community
tRPC & React Patterns: Router Factories
This post comes in 2 halves: tRPC Router Factories Consuming Router Factories in a React...
Solution
Alternatively you can use a Zod Union type on the input