Revisiting ‘Why I’m not a TypeScript fan’ one year later…
About one year ago, I published a blog post title Why I’m not a TypeScript fan. I had some strong opinions of why I didn’t use TypeScript. A few months after I published the post, Gaurav Seth reached out to talk about my post. He surprisingly agreed with many of the pain points I mentioned and said they were working on making this experience much smoother. Long story short, after that conversation I decided to give it a trial run on a side project before taking it to the big times with my project at work. Before I talk about that experience, I want to go through my points I had previously raised and talk about them shortly in retrospect.
Point #1 — Not the standard
Point #2 — You know its gonna happen
Point #3 — Its been around and gotten no ❤
Point #4 — Not Community Driven
This is somewhat true and not at the same time. Yes, Microsoft controls the outcome of this, however, they rely heavily on the community when building these new features into the language. Specs are drafted and posted long before any implementation is started. Microsoft’s position on the board helps them have intimate knowledge and inside details to arguments of why or not to do certain features.
Point #5 — A square in a circle hole (types in dynamic langs)
Adding a type system to any dynamic language is gonna be a tough mission. TypeScript surprisingly does an awesome job about type inference of the dynamic language. I think there is a sweet spot we need to find as a community and I think languages like TypeScript and Flow will help guide this path.
Point #6 — I’m a Babel fanboy
I still fancy Babel but after using it for about two years, the plugin system over complicates things and encourages you to write unstandard code. Its also surprisingly slower at compilation than TypeScript. Many of the plugins I used with Babel are available out of the box in TypeScript and the other things shouldn’t be at the compiler level and I’ve moved to Webpack plugins.
Point #7 — TypeScript Definitions
This still isn’t that great but its getting much better. The more type inference TypeScript can add to its language services the more it can rely less on types of non-typescript libraries. Today there is type libraries for almost any library you are using and the implementation of wildcards for modules makes it easier to just use non-typescript libraries and add the types later.
My experience to date
The first time I tried TypeScript it was version 1.8. During this re-evaluation phase I started with 2.1. The developer difference between 1.x and 2.1 is substantial and I give Microsoft HUGE props for that effort. There is so many advantages that using types can offer that you can’t do with a dynamic language, such as:
- AoT — Angular can pre-compile code for optimization far beyond tools like Uglify. It can only do this because of the type system.
- Refactoring — Webstorm and others tout the ability to refactor but to be honest I don’t trust it. With Types you can feel confident that it can do the introspection required to pull this off and during compilation be confident it worked.
- Productivity— By adding types and type checking in your editor, you can feel more confident about the code you write working the first time, catch more errors before having to refresh thus improving your productivity. Yes, its a pain but it will pay off orders of magnitudes in the end.