The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Catching JavaScript Mistakes with TypeScript

Catching JavaScript Mistakes with TypeScript

5:13
The TypeScript compiler is a powerful tool which catches mistakes even in vanilla JavaScript. Try it online at the [TypeScript Playground](http://bit.ly/catching_javascript_mistakes), zero setup required.
Watch this lesson now
Avatar
egghead.io

The TypeScript compiler is a powerful tool which catches mistakes even in vanilla JavaScript. Try it online at the TypeScript Playground, zero setup required.

Avatar
Bharat

An excellent screencast. Now that Angular 2.0 is being written in Typescript, it is important to know it well. Question for you: when would the modern browser start directly supporting TypeScript and we can do away with intermediaries. The reason I ask is that for awhile, I used Coffee Script. Soon I realized that debugging my code was a hassle, so I went back to the plain Javascript. If Typescript can run natively in the browser then it becomes a compelling story, since the benefits are huge.

In reply to egghead.io
Avatar
Robert

Hi Bharat,
I would estimate a minimum of 5 years before multiple browsers would support TypeScript. It would first need to be at least a proposed ECMAScript standard. ECMAScript 5 was finished in 2009. ES6 has been in the works for about 5 years, and hopefully will be complete this year.

In reply to Bharat
Avatar
Robert

But it sounds like your main concern is debugging a transpiled language. I'm curious, when you worked with CoffeeScript, did you debug the original code using source maps? Or were you debugging the generated JavaScript?

The TypeScript debugging experience is enjoyable for several reasons:
1. There's good support for source maps from modern browser debuggers, because the landscape of languages transpiling to JavaScript is huge now.
2. IDEs like Visual Studio and Webstorm/Intellij can debug TypeScript source in their own debuggers.
3. TypeScript generates clean, normal-looking JavaScript.
"Microsoft's TypeScript may be the best of the many JavaScript front ends. It seems to generate the most attractive code." -- Douglas Crockford, author of JavaScript: The Good Parts
If you should need to debug the generated JavaScript at times, it will be easier to follow than the output of some other languages.

In reply to Bharat
Avatar
Bharat

Hello Robert,
Thanks for your thoughtful answers, I appreciate it. Normally, I get an email from Egghead that a response has been posted to my question or topic of interest, so I can respond in a more timely manner. This time, I did not get one. Hence the delay.
Anyway coming back to the discussion, I have not used source-maps to debug the CoffeeScript code. I am a full-time Ruby on Rails developer who uses Javascript/Coffeescript 'Sprinkles' to make my server-pages more interactive. Now, I am venturing into pure client code talking to a server API, so my knowledge of SPAs is somewhat limited. I am maintaining a Rails application with 'heavy' sprinkles of Coffeescript code. I find less and less attractive to maintain it especially while debugging. I am converting most of my Rails Backbone heavy Javascript pages into Angular/Rails and while doing so, I am also replacing Coffeescript with Javascript. I got interested in Typescript after watching your short screencast and also ng-conf announcement of the shared partnership between Microsoft and Google in using Typescript as the development platform for Angular 2.0.
I would love to see more screencasts from you on how to configure WebStorm 10 which was just released to write Typescript code and more importantly, debug it. Also, more screencasts on how to 'deploy' the generated/transpiled javascript code in applications would be very useful too.
Thanks.
Bharat

In reply to Robert
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?