3 ms·
TypeScript is really about type safety within the confines of your application. You can address the unsafety at the edges with something like io-ts.
by samhh 6y ago
TypeScript is really about type safety within the confines of your application. You can address the unsafety at the edges with something like io-ts.
- diffrinse 6y agoBut this is a niche application of TypeScript, most day-to-day front-end devs I've interviewed aren't reaching for fp-ts, let alone io-ts, whatever the benefits. Even then, why not just use any one of Elm, PureScript, Reason, ScalaJS, etc? Why implement yet another FP runtime? If something like this is the surest way to make optimal use of TypeScript then I feel like we're just right back where we started. For most devs, I'd wager they're still ending up writing all the same tests they were before TypeScript. tsc even offers to just consume jsdoc annotations for crying out loud. If its just some kind of type convention sandbox, what did it really bring to the table?
- samhh 6y agoElm's got questionable support; I wouldn't feel comfortable recommending that at work, it'd be irresponsible. PureScript I really like but it's a massive jump from JS/TS to PS/HS. All of these languages are harder to abandon than a library in the same language you'll keep using if you decide against the paradigm down the road. Do I like this compromise? Not really, but it makes sense. Also, advertising use of a functional language might open you up to candidates who wouldn't otherwise apply.
- Shacklz 6y agoWholeheartedly agree and would like to point to another library that is capable of providing runtime typechecks: https://github.com/vriad/zod https://github.com/vriad/zod It doesn't come with the fp-approach that io-ts takes, and has, in my opinion, significantly better error reporting. Just plugging this here because I believe that zod is grossly underused :)