It is fairly complicated to keep things up and running in such a big codebase when I have to defer error checking to the runtime environment and different people contribute code. The nature of the code I write is mostly visual. Things that a human being won’t be able to spot whether they are right or wrong tend to be quite complicated to automate, either at unit or functional testing levels. For example, is that gradient-filled shape right ?, etc.
Basic features for a typed language, like code refactor, keeping up with correct VM code for performance or hinting code for performance is something so tied to the core of my development that I simply don’t want to deal with it on my own.
For this and so many other reasons I took a shot on Typescript.
Conclusion: it pays by itself after 10 minutes of using it. Specially when putting the stress in long-term maintainability and code quality.
Let me enumerate some of the goods I get while writing Typescript code:
- Refactor: my IDE recognizes the code semantically. It allows for deep type and elements refactor on-the-fly.
- ES6: Typescript brings to the table many ES6 language features. By the time ES6 is around, all my typescript code will almost be a one-to-one mapping which does not need any change.
- Solved extension mechanism. It ships with a very simple prototypical extension mechanism.
- Solved modularity. Module information will be written for you.
- Super light overhead. Resulting code is just the original code without the type information.
- Since 1.4, union types and type aliases will leverage the Typescript capabilities, switching from type:any to a union type.
- No learning curve at all.
Nowadays, there are Typescript mapping files for all major libraries around: webgl, nodejs, (node io ?? :), webaudio, etc. And being myself so close to HTL5 gaming, most modern HTML5 engines are either written in Typescript, like CocosJS or Egret, or have Typescript mappings like Phaser.
I’d rather have a compiler on my side. Ever.