Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News TypeScript Released to Improve JavaScript Development

TypeScript Released to Improve JavaScript Development

This item in japanese

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.

Rate this Article