How's TypeScript?

Created: 2017/01/15 20:51:53+0000

I had planned to complain about TypeScript because I couldn't generate the doc the way I wanted (documentation generation matters). Then I found the flag to fix it so I decided to say something nice.

Yes, TypeScript is a bit better than JavaScript. No, I'm not going to change my website to use it any time soon but that is because I'm tired of rewritting it.

I had implemented a simple JavaScript library and application to poll and parse a JSON resource. Then I asked myself, why JavaScript? I had in the past tried out ClojureScript so decicded to give TypeScript a go.

I rewrote the JavaScript code progressively. Porting one file at a time until everything but the tests was TypeScript. Working this way I didn't find any type errors. Aside from when I tried to figure out how to express the type signature I needed for something like an array of callbacks. What I mean is that the type annotations did not find a nest of hidden vipers in my code. My code was not more type-safe after porting to TypeScript than before.

That my code is not safer now is not a great surprise as it worked. I ran it and everying functioned as it should. No exceptions were thrown. I wasn't trying to call methods on objects that did not have them. I wasn't trying to call undefined. It made it very clear that type systems catch errors at compile time that would generate runtime errors.