Why I’m NOT a TypeScript Fan

This week a few different people have tweeted to me asking about my feedback on TypeScript ( mainly because they know I’m not a fan ). I finally jotted down my thoughts and thought I would share.

Warning: These views are mainly opinions and I have all the respect in the world for the TypeScript team. Also, its worth noting I’ve only had about 3 weeks experience with TypeScript ( 2wks in Node 5.x and 1wk in Angular2 ).

Not da standard

TypeScript is Microsoft’s own take on JavaScript.

Technologies like TypeScript that have competing open-community / open-source / spec driven implementations have a history of failing or never really taking off. Just think about these good ole ones: Flash, Silverlight, CoffeeScript.

If you have a large code base, picking TypeScript is something your going to be living with for a long time. I’d be will to bet in 3 years JavaScript will still be around without a doubt but I can’t say the latter for TypeScript.

You know its gonna happen…

Its inevitable that types are going to land in JavaScript sooner than later. To be honest, I’m surprised with all the ❤ JavaScript has gotten lately its not stage-0 by now. As soon as those land, things like TypeScript will be obsolete and technical debt to remove.

TypeScript has had their own module system for some time now. When ES6 Module syntax came out, they now encourage you to use that instead ( which is great ) but you can see a pattern here.

Its been around and gotten no ❤

TypeScript has been since 2012!!! I believe the only reason its gotten popular lately is because of Angular2. I think thats kinda a red flag in my book but thats just me talking…

Not Community Driven

I don’t see a lot of community involvement driving the spec / grammar / language like I do with even experimental features I see in ES*. I could be looking in the wrong places but shouldn’t they be looking to the community and only building that instead of implementing C# in JavaScript?!

A square in a circle hole

Adding typing into a non-typed language is always gonna be a hard mission to accomplish. TypeScript feels like it put types first and then JavaScript came in. That makes it really odd when you try to do things that have always been in JavaScript or are even new that don’t fit that paradigm.

I’m a Babel fanboy

Babel is the ****! About a year ago if you would have asked if I was gonna use a transpiler I would have told you that you were crazy. Sourcemaps, gulp/grunt/watch/build/etc just sounds like a nightmare but dang I’m hooked.

Babel’s plugin architecture implementation is amazing. I love being able to use the latest stage-0 features. Now I realize I just ranted above about non-standards and whatnot but come on, these will be pretty close to what actually lands a lot of the time and a find/replace can update me. Plus using these stage-0 features in real-life helps validate or invalidate the feature and give valuable feedback improving the community. The ability to target multiple environments such as node 4/5 or the browser is amazing too.

TypeScript can only target ES3/ES5/ES6 and your like well isn’t that all you need? Well Node 5.x only implements some parts of ES6 so your left in this odd middle ground with TypeScript. If you go all the way back to ES5 and are running Node 5.x then your polyfilling a lot of things it can already do which results is more complex output that is harder to debug.

TypeScript Definitions

TypeScript requires definitions for all the files you are using in your application. Makes sense right? It needs to know about everything and those types so it can compile stuff for you. But what if you use a library that isn’t written in TypeScript which is most libraries. Your kinda in a tough spot, if your using a really popular library there is likely a TSD out there that you can use but otherwise you have to either write the TSD yourself or mock the outputs. More work, more headache, why is there not a way around this yet? There is a bug but its still not resolved yet, hopefully soon!

Whats in the box?

I ❤ to use all the latest and greatest. So when I went to TypeScript I started trying to use things like stage-1 and stage-0 features only to find out some of them weren’t there but others were. The reason why many of them aren’t there is because they are going to take some serious re-jiggering to accomplish in a typed language ( spreads, destructuring, etc ). But given the nature of the language I found some that were stage-0 were actually there ( decorators, etc ). So I constantly hit walls on what I could and could not use. In general the TypeScript team is only implementing stage-3 features.

You can use as much or as little as you want

I think I’ve heard about 100 times now. What they don’t tell you is that you do HAVE to have some type implemented. So what you end up with is a bunch of any types all over your code base. This makes migrating to TypeScript kinda a challenge.

What about FlowType?

Given my strong opinion above you would probably think, ya he’s gonna hate that too but actually I don’t. I feel like FlowType puts JavaScript FIRST and types just lay on top. It feels way more natural to me when I’m using it. There is also a Babel compiler ;) plugin so I can use my favorite compiler for it too!

But your probably still saying but its still not the standard and your right! But you know that types ARE gonna happen sooner than later. TypeScript and FlowType have similar type declaration which poises this as a good entry point for us to come together. And you know what, if it doesn’t take off there is always the strip-flow-types Babel plugin and I’m back to basic JS ;).

I would love to hear feedback on why you think otherwise or if I missed something! Follow me on Twitter and Github to stay fresh on the latest JavaScript buzz!