Super Charge Your JavaScript Development With TypeScript

Though my current writings on this blog may not show it, I’m more than just a Tridion and .NET nerd. Don’t get me wrong, I’m a huge .NET fan. But I love other technologies as well… one of them being JavaScript. Sure JavaScript may have gotten a bad rep as being a slow, crappy client side scripting language. And due to its heavy use in browsers, a lot of JavaScript development is done by non-programmers who don’t know any better, so a lot of what you see out there could have been done poorly in pretty much any language if done by the same group. But underneath the hood when you dive into its capabilities, there lies something beautiful (and not so slow when tuned correctly!). And I truly believe that there also lies the future of web technologies.

I’ve been working heavily with NodeJS in a couple of my side projects. For those who have not heard of this, NodeJS is a server side JavaScript technology. Now this is where I may get some eye rolls from fellow colleagues… JavaScript on the server? Now that’s gotta be buggy and slow, right? And at one point in my life (probably just a little over a year ago), I would have full heatedly agreed that the server was no place for some error prone JavaScript. But after much investigation into Node (and thus into JavaScript as well), I was in for such a surprise. A pleasant one.

Even with the new found love and understanding for this misunderstood technology, there was still something missing in my JavaScript project. Now I’m not talking about a project of a few hundred lines of code or less. I’m talking about one that has expanded into thousands. And the maintainability, especially for someone who has grown use to his conveniences of the tools in Visual Studio, was slowly becoming a nightmare.

And then recently, a colleague of mine introduced me to TypeScript, a “typed superset of JavaScript that compiles to plain JavaScript”. Yep, we’re talking about strongly typed JavaScript, classes, interfaces, and even some ES6 future features. The best part is, unlike some of those other languages that compile into JavaScript, TypeScript IS JavaScript. You can copy paste existing JavaScript code into your TypeScript file, and it’ll work. The best part is, with Visual Studio 2012 (and the plugin), you now have full intellisense support with your TypeScript JS, refactoring, and even code lookup (yep, that’s right, F12 it).

So, those maintainability issues that I was having? Yep, you guessed it… I’m currently in the process of re-writing my code into TypeScript style classes (not so much trouble since I was already using classes in JavaScript, function style). I’ll probably write up some posts on things that I’ve learned, probably maybe even an example of a GUI Extension with it as well. In the meantime, if you’re someone who’s writing some pretty complex JavaScript applications (client or server), I’d definitely recommend giving it a try. It’s not perfect yet, bit it has rekindled the fun in my JavaScript projects.

2 thoughts on “Super Charge Your JavaScript Development With TypeScript

    • The IDE features definitely make it worth checking out! I’ve played with CoffeeScript a little… with that its really a different language that compiles down to JavaScript, and I’m not a big fan of the syntax. With TypeScript its extended JS (much of that futures that might be the style of ES6) that compile down to a compatible version of JavaScript that you specify.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>