3 ms·
I am really not getting this. If you run Typescript on both ends, can't you just share the source code that defines the types?
by markoutso 5y ago
I am really not getting this. If you run Typescript on both ends, can't you just share the source code that defines the types?
- hu3 5y agoYou kinda can share function signatures with TypeScript's import type. And that's what tRPC does but adds some generics in the middle to make things seamless. Explanation here: https://colinhacks.com/essays/painless-typesafety https://colinhacks.com/essays/painless-typesafety
- ricardobeat 5y agoYou could argue that this is actually adding a lot of (nicely knit) seams.
- colinmcd 5y agoI think that's a good characterization!
- colinmcd 5y agoBasically tRPC lets you define a router containing all your endpoints in a single structure. Then you can import the type definition of your router and make typed API calls without needing to wire everything together with types.