TypeScript == Maintainable and “Best Practice” JavaScript
If you are writing JavaScript but not using something like Coffee Script, TypeScript or Script# then you are missing out on hours of productivity and a far more pleasant js coding experience.
Coffee Script has been around for a while now but I put off learning it because I didn’t want to add yet another layer of tools/languages into my already overflowing brain. But thankfully I’m on a project where we are using TypeScript and I think it will have a similar type of productivity impact that tools like ReSharper have.
TypeScript is a JavaScript compiler and static typing extension for JavaScript. When you write TypeScript it compiles to JavaScript at runtime but provides you static typing during development. You can write plain JS right next to TypeScript because TypeScript extends JS. You get things like Interfaces, Classes and Inheritance… not to mention typed parameters, properties, etc.
In my first experience with TypeScript I took a gnarly (but “best practice”) JavaScript module that was 200 lines to provide the exact same functionality in just 100 lines. To be fair the outputted JS was about 200 lines but the point is the TypeScript file (which I maintain) is only 100 lines!!! This is a huge complexity reducer and productivity booster.
I think I’m sold.
Get started with this great video from Anders Hejlsberg on Channel 9.
P.S. How does TypeScript play with JQuery, Knockout and other libraries you ask? Well, anything you write runs as JavaScript — but if you want all the auto-complete and static type checks then you’ll need the “Type Definitions” for each library… thankfully there is an awesome project which provides these for virtually any popular JS library.
https://github.com/borisyankov/DefinitelyTyped (or on Nuget)
UPDATE:
Scott Hanselman has a great post on TypeScript that you should checkout.

