Microsoft TypeScript: “Syntactic Sugar” For JavaScript

Are you involved in application-level development using JavaScript? If so, this news might interest you!

A few weeks ago, Microsoft unveiled a new JavaScript-like programming language named TypeScript. At its most basic level, TypeScript operates by translating code into JavaScript (that enables its apps to run in any browser). The language itself is pretty similar to JavaScript in terms of its syntax, but with a good set of additions of its own, such as optional static typing, among other things.

TypeScript

Dubbed as a typed superset of JavaScript, TypeScript complies to plain JavaScript, thereby enabling you to use the well-known JavaScript syntax and semantics for building your apps. Wish to build large apps? TypeScript comes with all the tools you need — classes, modules and interfaces!

In the words of Microsoft, “TypeScript is syntactic sugar for JavaScript.”

Sounds fun? Need a demo? Let’s take, for example, the extensive use of type inference in the language. If you type the following line of code:

[js]var j=0;[/js]

TypeScript will figure out that the variable ‘j’ has the type number. Similarly, if you type the following:

[js][/js]function i()
{
return “awesome”;
}
{/js}

TypeScript will infer that the function i() has the return type string.

So, what all does TypeScript bring to the table? Apart from optional static typing, we also get class declarations, support for modules and a Visual Studio Plugin. The language itself is active on Codeplex, and comes with an Apache 2.0 open source license.

You can find out more about the TypeScript project by visiting the homepage, or simply grabbing hold of the specifications’ PDF or the source code.

Needing some indepth info? Check out this video:

What do you think of TypeScript? Another language in the pool of programming languages? Or a much-needed innovation, trying to address the issues raised by Dart, but simultaneously adhering to JavaScript? Have your say in the comments below!

Comments