DEV Community

Discussion on: Should we explicitly type the output of all functions (TypeScript) ?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

I wouldn't. But if I consider doing, I would also consider writing TSDoc.

Actually, if I fallback to JavaScript, I almost always write JSDoc.

As for Type-checking, I only care about IDE. But for runtime, I would perhaps use runtypes or zod. TypeScript's typing is not to be trusted.

Collapse
 
yanns1 profile image
Yann

Interesting, I would have not imagine that TS was not perfectly type safe for runtime but that's true indeed, because it compiles to JS anyway.
Thanks for sharing these tools, I'll check out !

Collapse
 
devhammed profile image
Hammed Oyedele • Edited

There is a new Type-checker that does just that for both development and runtime, check out Hegel and the best thing is you already knows it if you work with TypeScript or Flow and also with better type inference.