This story was written by Keith Dawson for UBM DeusM’s community Web site Develop in the Cloud, sponsored by AT&T. It is archived here for informational purposes only because the Develop in the Cloud site is no more. This material is Copyright 2012 by UBM DeusM.

Microsoft's TypeScript Benignly Extends JavaScript

Syntactic sugar for better tooling and large-scale development.

The inventor of C# introduces Microsoft's JavaScript superset, TypeScript, which compiles to JavaScript. The entire package is open source.

From the days of the Microsoft antitrust trial in the 1990s, the company became known for the "embrace, extend, and extinguish" strategy it tended to employ when approaching any standard that had not been invented in-house. (The phrase came from internal Microsoft emails of the time.) So the industry has been understandably wary of the company's motives whenever Microsoft announced it was embracing some standard -- particularly if it was offering to extend it as well.


With the announcement of TypeScript, Microsoft appears to be doing everything in the open in order to allay any fears before they arise. From what I have seen on social media and in comments on Microsoft's own sites, the community for the most part is reacting favorably to TypeScript and to the openness with which Microsoft is treating it. (An exception is open-source evangelist Ryan Paul, who pointed out that a year ago Microsoft publicly dissed Google's proposed JavaScript replacement, Dart, saying that JavaScript didn't need replacing.)

TypeScript is a formal superset of JavaScript and a compiler that produces JavaScript out the back end. Every JavaScript program is already a TypeScript program, as Microsoft VP S. Somasegar stresses in the announcement. His elevator pitch: "TypeScript is a superset of JavaScript that combines type checking and static analysis, explicit interfaces, and best practices into a single language and compiler." As developer Aaron D. Wells tweeted: "First take: #typescript starts addressing the deficiencies that #javascript has had for years, in a way that doesn't break anything."

In the language field, some heavy hitters are behind TypeScript, according to The H. The project lead is Microsoft Technical Fellow Anders Hejlsberg, father of C#. Also on the team are Steve Lucco, who was instrumental in Microsoft's Chakra JavaScript engine, and Luke Hoban, who is involved in JavaScript standardization (as ECMAScript). speculates that Hejlsberg took on this project because "a shift of power within Microsoft has made C#, and the whole .NET system, look less attractive... the re-imagining of Windows [with Windows 8] brought the limelight back on C++."

Hejlsberg's introduction to TypeScript is available as a SilverLight video. He motivates the language by noting that JavaScript was never intended for the uses to which it is being put today and lacks many of the structures that allow robust tooling and debugging. TypeScript adds the missing pieces: static types, classes, and modules, all of them optional features.

This early preview of TypeScript is integrated into Visual Studio 2012, and Microsoft has created what look like fairly rudimentary integrations for the Sublime, Emacs, and Vim editors. (Commenters on this Microsoft page urge the company to push the integrations in all three editors' native package-control environments.) There is an npm package for installing the compiler on a server running Node.js.

You can learn more about TypeScript and play with and download sample code on the language's public page. The code behind TypeScript is available as open source under the Apache 2.0 license (the TypeScript compiler is itself written in TypeScript). Microsoft hosts it on their own CodePlex repository, but commendably offers instructions for cloning it in git. The language specification itself is available under an Open Web Foundation's Final Specification Agreement license.