ianI
tRPC2y ago
2 replies
ian

Complex type inference on router outputs?

What are the best practices on complex outputs from routers and typing on the FE? We are doing quite a bit of munging of data from multiple sources, so there's no real concept of an upstream "primitive" as there would be in a simple trpc + nextjs + prisma setup.

How is everyone doing typing in a scenario like this? It feels brittle to bind a UI element to the response from a router as that will intrinsically bind those two elements together, making the component non-reusable.

Is there a typing layer for trpc that sorta behaves like GQL, where you get a meta layer of types from the router responses?
Was this page helpful?