TypeScript 0.9 Released
Written by Ian Elliot   
Wednesday, 19 June 2013

TypeScript, Microsoft's replacement for JavaScript, has reached 0.9, a release that is important for the inclusion of Generics and a re-engineered compiler.

TypeScript was first released in October 2012 as a language to help Microsoft developers write large applications for the web, server, and Windows desktop.

It is an open source project but has active participation from Microsoft personnel, including Anders Hejlsberg, who prior to TypeScript was known for C#.

The MSDN announcement of the new beta explains that Generics was most highly requested feature by users of the original 0.8 version and states:

"generics enable capturing relationships between inputs and outputs in APIs, enabling richer type checking for better error reporting and tools.  For example, generics allow the typing of the Array#map function from JavaScript to relate the element type of the array with the parameter to the callback function (‘T’ below), and the return type of the callback function with the return type of ‘map’ (‘U’ below).

interface Array<T> {

// ...

map<U>(callbackfn: (value: T,
       index: number,
       array: T[]) => U): U[];
// ...

var array: Array<string> =
        ["John", "Sam", "George"];
var lengths = array.map(
      (val, idx, arr) => val.length);


The idea being that the types of the variables used as T and U can be checked - even if this involves type inference because the programmer didn't declare a type. 

Of course, if you don't adopt strong typing like the original JavaScript then you don't need to invent generics to complicate things. It is all too easy to see TypeScript as "fixing" the problems with JavaScript, but it really only moves JavaScript in the direction of languages such as C#.  If this isn't a direction you want to go in then it becomes a pointless exercise. 

Although generics are the big new feature, there are some others worth mentioning. In particular overloading of functions based on the type of constants. For example, if you call createElement with a general string the result is taken to be of type HTMLElement, the most general type. If the string is "canvas" then the return type can be assumed to be HTMLCanvasElement and so on. Again, the point is that it allows compile time type checking to make sure you aren't using an HTMLCanvasElement as an HTMLDivElement, say. Once again, if you think that JavaScript and duck typing is good enough, this will not impress. 

We also have fully typed enums:

enum Color { red, blue, green }
var myColor = Color.red;

and declaration mapping allows you to do things that are easy in JavaScript but in a type checked way:

function readInput(
 separator = readInput.defaultSeparator) {
// read input
module readInput {
 export var defaultSeparator = ":";


As well as the syntactic and type checking sugar, the compiler has been improved so that it scales better and provides better incremental compilation. Unfortunately this improved quality costs a little and the 0.9 compiler is a little slower. 

In this video Anders Hejlsberg, creator of the new language, Steve Lucco, TypeScript's co-designer and responsible for its original compiler and Luke Hoban who has also been heavily  involved in the project discuss feedback from its early adopters, the new features in this release, starting with TypeScript's generics and how this differs from those of other languages.


If you are interested in language development it is interesting to see the way that TypeScript is evolving to allow the freedoms that JavaScript has built-in while implementing compile time type checking. One of the criticisms often leveled against strong typing is that it is an idea that starts out simple but progresses to become increasingly complicated as the language evolves to allow the programmer to do more. 





More Information

Announcing TypeScript 0.9

Related Articles

TypeScript - Microsoft's Replacement For JavaScript

Getting Started With TypeScript

WAT! JavaScript, Ignorance And Prejudice

JavaScript The Evil Parts - You Can't Maintain It


To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin,  or sign up for our weekly newsletter.


raspberry pi books



or email your comment to: comments@i-programmer.info



Meet Ambidex and Rookie From NAVER

Robots may not be ready yet for the great takeover of jobs that some people fear, but in South Korea, where there are 1,000 robots per 10,000 workers, service robots are finding a role. 

Google Releases Vertex AI Agent Builder

Google has launched Vertex AI Agent Builder, alongside new open-source language models for the Vertex AI platform. The announcements were made at the Google Cloud Next 2024 event.

More News

Last Updated ( Wednesday, 19 June 2013 )