DEV Community

Discussion on: When TypeScript lies... and how to make it honest

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Great article. Would you mind also adding tsoa to the list of codegen tools?

Collapse
 
yakimych profile image
Kyrylo Yakymenko

Thanks! Sure - let me get this right - tsoa generates a swagger spec for an API written in nodejs/TypeScript? And then one could use the same TypeScript types on the frontend in order to avoid a mismatch?

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Yup, but tsoa additionally does validation at runtime so that the data that comes in is exactly what the types say. Think of it as an automatic io-ts for every route on your NodeJS service! :)

It keeps the garbage data out so your types are never a lie. And it saves tons of code.

Thread Thread
 
yakimych profile image
Kyrylo Yakymenko

Sounds great! I almost feel it's a shame we have our API in F# :)
I've added a sentence about tsoa, thanks again for the tip!