TypeScript is really, really good.

I recently abandoned my trusty old Windows 8.1 laptop in favour of a Macbook.

This was for a couple of reasons – firstly, the Windows machine had been degenerating over time to the point where the sound no longer worked, sleep mode caused problems, plugging a charger in would cause the system to hang, and so on. All things that I could’ve dicked around with and potentially resolved, but it was getting old and I saw a good deal for a Macbook online.

Anyway – I’m now using a Mac. Which is weird, as a (primarily) C# developer professionally. Luckily, I do lots of Javascript in my spare time, which has lead me to start playing around with TypeScript and Visual Studio Code – the new IDE that I didn’t know about. Which as it turns out, is also very, very good.

TypeScript: http://www.typescriptlang.org/
VS Code: https://code.visualstudio.com/

Why is TypeScript so good? It’s just very easy to use and the benefits, especially when coupled with a smart IDE like VS Code, are immediate. You get all the compile-time validation benefits of a strongly typed language like C# without them being enforced at every opportunity.

This is a significant efficiency benefit when working on a reasonably large Javascript codebase. As an example, I’m currently writing a game engine in Javascript, which is thousands of lines of code. Porting it to TypeScript, and using type annotations (where they make sense) has significantly increased my productivity and reduced errors.

The workflow change hasn’t been massive either – I simply use the built-in task runner provided by VS Code to compile the TypeScript, and ensure it generates source maps for js > ts in order to be able to debug in-browser.

Using TypeScript in this way eliminates a whole host of mistakes and potential pitfalls that can lead to wasted time and effort.

Leave a Reply