BT

TypeScript Released to Improve JavaScript Development

by Jeff Martin on Oct 03, 2012 |

Microsoft released TypeScript this week as part of its efforts to improve JavaScript application development. Their new language is a superset of the JavaScript specification that adds type checking and static code analysis while still generating native JavaScript. These features are intended to enable developers to more easily scale JavaScript for larger application development while benefiting from the improved tooling options type checking can provide. Existing JavaScript code can be used under TypeScript immediately and since the TypeScript compiler produces pure JavaScript it can be run on existing JavaScript capable platforms.

To provide the benefits of compile-time checking and IntelliSense to existing JavaScript libraries, developers use declare files which “... are a thin shim of type information describing the interfaces expected in the existing JavaScript.” TypeScript joins a field filled with numerous projects to either improve or replace JavaScript including CoffeeScript and Google's Dart:

CoffeeScript describes itself as “... an attempt to expose the good parts of JavaScript in a simple way.” Like TypeScript, CoffeeScript compiles to JavaScript and seeks to be a cleaner, dynamically typed language. Consequently it cannot support static analysis and is not designed to.

Google's Dart is also dynamically typed, but does offer optional static type annotations. Per Google, “Dart aims to be like JavaScript, but faster, more regular, and more scalable to large programs.” Dart code can be compiled to JavaScript or run directly in the Dart VM.

TypeScript is available under the Apache 2.0 open source license and the source code can be downloaded now from CodePlex. The TypeScript compiler and a Visual Studio compatible plugin can be downloaded from Microsoft. The included Visual Studio plug-in does support Visual Studio Express 2012 for Web. Alternatively, sample syntax files have been released by Microsoft for the Sublime Text, Emacs, and Vim editors.

Mono's Miguel de Icaza noted that the Emacs plug-in does not currently compare to the features offered by Visual Studio, and so lacking IntelliSense it is “obnoxious to use”. The end result is that language currently favors the Windows development environment, although there is nothing that could prevent this from changing in the future.

Regarding the overall design of the language itself, de Icaza was generally positive. One difference he noted in comparison to Dart is that while TypeScript compiles exclusively to JavaScript, Dart can target its native VM providing the ability to use the “type information to optimize the quality of its] generated code”. This points to a difference in purpose: TypeScript can run anywhere JavaScript is supported, but the (less popular) Dart VM would be required to take advantage of those code optimizations.

For additional information on TypeScript, and a demo of the langauge, Anders Hejlsberg provides an introduction to the project on Microsoft's Channel 9.

Hello stranger!

You need to Register an InfoQ account or to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

TypeScript vs JS by Gerardo Gonzalez Cruz

I don't know why i have to learn another script language if this compile his output to JS? Backbone is really good, tempojs is cute. The big problem is browser compatible to execute JS without no problems. We have WebGL, Audio and Video API and all these technologies are in this moment incompatible for all render engine browsers.

Re: TypeScript vs JS by Roopesh Shenoy

One thing TypeScript has got right (vs other compile-to-JS languages) is that the its a superset of JavaScript, not a completely new language.

Re: TypeScript vs JS by Mark N

I don't know why i have to learn another script language if this compile his output to JS? Backbone is really good, tempojs is cute. The big problem is browser compatible to execute JS without no problems. We have WebGL, Audio and Video API and all these technologies are in this moment incompatible for all render engine browsers.

Well for starters = "[TypeScript] adds type checking and static code analysis ". I have had the joy of supporting other peoples code both in something like Java/C# and also in something like JavaScript. Having type checking makes this a whole lot better, even with a pretty bad codebase. In the olden days with VB ... the first thing you had better do when creating a new app is to set "Option Explicit". ;)

The State of Javascript by Gerardo Gonzalez Cruz

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

4 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT