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
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.
You know its gonna happen…
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
A square in a circle hole
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 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?
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 ;).