This project looks interesting! I have used a similar project called tsoa [1] and have appreciated that it generates an OpenAPI spec that can be consumed readily by many other clients, even outside the JS ecosystem. Does TRPC have plans for a similar feature set? [1] https://tsoa-community.github.io/docs/
Yup, with the optional `output`-property we actually have all the type information needed to generate an openapi-schema. See this for more info: https://github.com/trpc/trpc/issues/1724
TRPC: End-to-end typesafe APIs made easy
51–59 of 59 posts
Re: TRPC: End-to-end typesafe APIs made easy
#52Not looking to actively bash anyones work here but I’m really confused on the value proposition here over something like gRPC which has a lot of substantial advantages from speed, to wide cross language support and has been battle tested in the most extreme scaling scenarios possible. A truly huge amount of time, money and optimization went into a project like that and has been proven to work well for years now. The…
There will be an openapi generator some time in the future so that could help with generating clients for other languages (https://github.com/trpc/trpc/issues/1724).
Re: TRPC: End-to-end typesafe APIs made easy
#53Not looking to actively bash anyones work here but I’m really confused on the value proposition here over something like gRPC which has a lot of substantial advantages from speed, to wide cross language support and has been battle tested in the most extreme scaling scenarios possible. A truly huge amount of time, money and optimization went into a project like that and has been proven to work well for years now. The…
You can't provide typesafety (with TypeScript) across the frontend and backend for multiple languages without codegen. There's no intention for this to be strictly JS, but there's no easy way to offer this for multiple languages. There will be an openapi generator some time in the future so that could help with generating clients for other languages ( https://github.com/trpc/trpc/issues/1724 ).
OpenAPI already exists and anyone can write a spec today and have code generated (servers, clients, models) today. Same principle as protobuf but the message and service description is much more verbose.
> tRPC to OpenAPI generator
So, … another level of indirection? Why would I ever pick this up when I can just use OpenAPI directly?
Re: TRPC: End-to-end typesafe APIs made easy
#54Not looking to actively bash anyones work here but I’m really confused on the value proposition here over something like gRPC which has a lot of substantial advantages from speed, to wide cross language support and has been battle tested in the most extreme scaling scenarios possible. A truly huge amount of time, money and optimization went into a project like that and has been proven to work well for years now. The…
You can't provide typesafety (with TypeScript) across the frontend and backend for multiple languages without codegen. There's no intention for this to be strictly JS, but there's no easy way to offer this for multiple languages. There will be an openapi generator some time in the future so that could help with generating clients for other languages ( https://github.com/trpc/trpc/issues/1724 ).
I don’t have a problem with the code generation personally, if anything I appreciate having something I can go and inspect if things go wrong so avoiding it isn’t an obvious plus to me.
Re: TRPC: End-to-end typesafe APIs made easy
#55Disagree here and it’s a bit disconcerting to see this as an opening premise.
Re: TRPC: End-to-end typesafe APIs made easy
#56Earlier quoted context omitted.
You can't provide typesafety (with TypeScript) across the frontend and backend for multiple languages without codegen. There's no intention for this to be strictly JS, but there's no easy way to offer this for multiple languages. There will be an openapi generator some time in the future so that could help with generating clients for other languages ( https://github.com/trpc/trpc/issues/1724 ).
I think maybe that’s the part I’m not getting. I don’t have a problem with the code generation personally, if anything I appreciate having something I can go and inspect if things go wrong so avoiding it isn’t an obvious plus to me.
In my experience, you can iterate more quickly without generation. I've used GraphQL and having a separate system to generate code and types was not a good experience. If not done properly, your schema and types can also easily be out of sync.
Re: TRPC: End-to-end typesafe APIs made easy
#57Earlier quoted context omitted.
I think maybe that’s the part I’m not getting. I don’t have a problem with the code generation personally, if anything I appreciate having something I can go and inspect if things go wrong so avoiding it isn’t an obvious plus to me.
Using TS type inference to its fullest is a major part of tRPC so I don't think it has much of a benefit to you if you're ok with generation. In my experience, you can iterate more quickly without generation. I've used GraphQL and having a separate system to generate code and types was not a good experience. If not done properly, your schema and types can also easily be out of sync.
Re: TRPC: End-to-end typesafe APIs made easy
#58Re: TRPC: End-to-end typesafe APIs made easy
#59Earlier quoted context omitted.
Hi, Servant user here: Haskell's type system is sound, which means that you can have type safety. TypeScript's type system is unsound, so every guarantee that you may think you have wrt. type safety go out of the window at the moment you start the typechecker.
Hey, don't be this way. Haskell's type system is also unsound (see: undefined, unsafePerformIO). Typescript has done an amazing job bolting an advanced static type system on top of a dynamically typed language. The edge cases of that type system exist, and are a bit more prevalent than Haskell's, but there exist a number of libraries in Typescript that take inspiration from Haskell libraries. This question is about t…