TypeScript–new language for Javascript Development

Just two days before Microsoft has officially announced the new initiative ‘TypeScript’ – a new language for cross platform, enterprise class JavaScript application development.

Why we need it?

Typical JavaScript lacks few missing pieces for full object oriented development. Developers would not be much flexible doing object oriented development using native ‘prototyping’ in JavaScript. It is really time taking if you would like to do large scale JavaScript development using ‘prototype’ in JavaScript and even more confusing to the developer on defining the scope etc.

Instead developers would be more flexible if they could do JavaScript development like any other object oriented language like C#, Java does.

That is how TypeScript is born.

TypeScript

TypeScript is a programming language that makes it easier to write cross-platform, application scale, JavaScript that runs in any browser or in any host.  TypeScript,  is a typed superset of JavaScript that compiles your code to readable normal JavaScript, can dramatically improve your productivity by enabling rich tooling experiences, all while maintaining your existing code and continuing to use the same JavaScript libraries you already love.

TypeScript extends JavaScript syntax, so any existing JavaScript programs work with TypeScript without any changes.

TypeScript is designed for development of large applications and when compiled it produces JavaScript to ensure compatibility.

TypeScript is a language extension that adds features to JavaScript.

  • Type annotations and compile-time type checking
  • Classes
  • Interfaces
  • Modules
  • Arrow functions (Lambda functions)

Compatibility with JavaScript

TypeScript is a superset of JavaScript. By default the compiler targets ECMA Script 3 (ES3) but ES5 is also supported as optional. A TypeScript application can consume existing Javascript scripts. Compiled TypeScript scripts can be consumed from JavaScript.

Existing frameworks such as JQuery and Node.js are fully supported. Type declarations for these libraries are provided with the source code.

Supported web browsers and platforms

Any web browser on any platform can run TypeScript as it is just compiled into standard JavaScript. A script can either be precompiled into JavaScript or compiled on the fly by including the JavaScript compiler for TypeScript.

The TypeScript Compiler

The TypeScript compiler, or tsc, is written in TypeScript that can be compiled into regular JavaScript that can be executed in any JavaScript engine in any host, such as a browser. The compiler package comes bundled with a script host that can execute the compiler.

It is also available as a Node.js package that is using Node.js as a host.

The current version of the compiler supports ECMAScript 3 by default. An option is allows to target ECMAScript 5 to make use of language features exclusive to that version.

Classes, despite being part of the ECMAScript 6 standard, are available in both modes.

<code>&lt;p&gt;&lt;strong&gt;&lt;u&gt;IDE &amp;amp; Tooling Support&lt;/u&gt;&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Microsoft provides a plug-in for Visual Studio 2012 as well as basic text editor support for Sublime Text, EMACS and Vim &lt;/p&gt;  &lt;p&gt;The TypeScript website has an interactive &lt;a href="/wp-content/uploads/2012/10/playground"&gt;Playground&lt;/a&gt; that provides a rich coding experience. &lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;u&gt;TypeScript is Free &amp;amp; OpenSource&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The TypeScript language specification is available under &lt;strong&gt;Open Web Foundation&lt;/strong&gt; and the compiler implementation is available as &lt;strong&gt;Open Source&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;You can find codeplex repository of TypeScript at &lt;a title="http://typescript.codeplex.com/" href="/wp-content/uploads/2012/10/typescript.codeplex.com"&gt;http://typescript.codeplex.com/&lt;/a&gt;&amp;#160;&lt;/p&gt;   &lt;p&gt;&lt;strong&gt;For more information on &lt;/strong&gt;&lt;a href="/wp-content/uploads/2012/10/www.typescriptlang.org"&gt;&lt;strong&gt;TypeScript&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; :&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Walk through the &lt;a href="/wp-content/uploads/2012/10/tutorial"&gt;tutorial&lt;/a&gt; . &lt;/li&gt;    &lt;li&gt;Try it out in the &lt;a href="/wp-content/uploads/2012/10/playground"&gt;Playground&lt;/a&gt; . &lt;/li&gt;    &lt;li&gt;Check out the &lt;a href="/wp-content/uploads/2012/10/samples"&gt;sample apps&lt;/a&gt; . &lt;/li&gt;    &lt;li&gt;Read the &lt;a href="http://go.microsoft.com/fwlink/?LinkId=267121"&gt;language specification&lt;/a&gt; . &lt;/li&gt;   &lt;/ul&gt;   &lt;strong&gt;Information References &amp; Courtesy:&lt;/strong&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="http://en.wikipedia.org/wiki/TypeScript" href="/wp-content/uploads/2012/10/TypeScript"&gt;http://en.wikipedia.org/wiki/TypeScript&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="http://typescript.codeplex.com/" href="/wp-content/uploads/2012/10/typescript.codeplex.com"&gt;http://typescript.codeplex.com/&lt;/a&gt;&amp;#160;&lt;/li&gt;    &lt;li&gt;&lt;a href="/wp-content/uploads/2012/10/Anders-Hejlsberg-Introducing-TypeScript"&gt;http://channel9.msdn.com/posts/Anders-Hejlsberg-Introducing-TypeScript&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="/wp-content/uploads/2012/10/microsoft-typescript-the-javascript-we-need-or-a-solution-looking-for-a-problem"&gt;http://arstechnica.com/information-technology/2012/10/microsoft-typescript-the-javascript-we-need-or-a-solution-looking-for-a-problem/&lt;/a&gt;&amp;#160;&lt;/li&gt; &lt;/ul&gt;
</code>