TypeScript: transition language to the future of JavaScript

This new Microsoft language allows you to use the capabilities of ECMAScript 6 and 7 right now, without waiting for their implementation in browsers.

It is the first programming language to be used temporarily. As a result of syntax similar to JavaScript and compiled in this language, after all additional functions are implemented by interpreters, TypeScript code can be replaced with JavaScript code. Generated first or resumed as is.
So developers can remove the compilation step in JavaScript code and TypeScript may disappear! This is different from what Dart offers, which offers the same features but wants to replace JavaScript in browsers.
This is a JavaScript set: You can take the code written in the latter, make it the source of TypeScript and add classes and interfaces to it, for example.

TypeScript is used in production with always positive reviews, as it significantly improves performance, and you never want to go back to JavaScript. The only noticeable drawback is slow compilation across large projects. This is the Angular 2 programming language (from Google).

The compiler is open source under the Apache license and is built with Node.js and Jake, a kind of Make designed for JavaScript projects, where macephiles are replaced by jakefiles. The source code itself is written in TypeScript, and converted into a unique TypescectServices.js file (compiler), so it uses Google's V8 interpreter!
Executable code is not provided directly for download (it can be produced independently), but is part of Visual Studio 2013 or as an npm module.

TypeScript vs JavaScript
Playground shows how TypeScript code becomes JavaScript

Static types

The var x: boolean form can be annoying in the first phase. Writing the number x or box x, as in C, would be easier. Following this logic, instead of writing the class x or should write the definition of x: class.
But this is nevertheless justified here by optional types: you can write var x and have a dynamic variable, and the type of which can change during processing, or add a static type. The type is explicitly variant, and this syntax is in the Asm.js or Julia string.

The language has the following types:

Functions

A function can have common arguments by overloading or combining.
Example of consolidation:

function(s:string | string[]) 

Classes and interface

The syntax of a class declaration is similar to that of ECMAScript 6 and is actually similar to that of most programming languages. The constructor is defined by the word constructor and this is added to reference the attribute in the class.

Exempli gratia:

class voiture {
  passagers = 4;
  constructor(personnes : number) {
    this.passagers = personnes;
  }
  
  mamethode(message : string) {
    console.log(message);
  }
}

var mavoiture = new voiture(2);

Inheritance occurs with the extends keyword:

class voiture extends vehicule { ... }

The constructor can call the constructor of an inherited class using the super (...) method.
Because attributes are public by default, only the private keyword is required to declare a participant private.
The word static-reserved can be applied to class members to divide assigned values among all inherited classes.

Legacy is translated into JavaScript with prototypes, and the rest of the elements are used only for compiler controls and are not converted. It is likely that the language will evolve for more accurate translation when ECMAScript is widely implemented .

Classes can be associated with interfaces. Example:

class moteur extends voiture {
  puissance : number;
}
interface voiture {
  passagers : number;
}

var mavoiture : voiture = { passagers : 4, puissance : 300 };

Thus, there is both heritage and composition, which is not offered, for example, by the Go and Dart languages. Unfortunately, this also seems unplanned for ES 6 and may force it to stay on TypeScript if it is used, as it can be extremely useful for rearranging code.

Other additions

I will not describe in detail all the TypeScript functions that are described in detail with examples in the documentation on the site, but will give an overview of other language features.

Missing features

Additions to ECMAScript that are already implemented in browsers are not mentioned in the latest TypeScript specification:

Why use TypeScript

?

TypeScript is becoming more and more popular, as evidenced by Google Trends statistics:

TypeScript vs les autres

The advantage of TypeScript over all other languages ​ ​ that are compiled in JavaScript is that it is embedded: You can reuse the JS file and include the functions added by TypeScript in it, and then rename the file from .js to .t.
And when a language develops, it is done with the functions defined in ECMAScript 6 onwards, and thus the JS overlay remains.

Creating a large JavaScript project requires TypeScript. The product code is optimized for JIT interpreters. The reusability of the code is greatly facilitated. And do not fear for the future, even the source code will be easily reused without a compiler. It has drawbacks, but can be filled by combining JavaScript code with TypeScript code. It does not solve all JS problems, because JS problems are not inherent in it, they come from browsers, DOM or ignorance of the language.
It basically solves the question of code suitability. And he saves us from using Dart, which will cut through web programming.

TypeScript. Official website. The language was created by Anders Heilsberg, who is also the author of Turbo Pascal, C #.
The authors of the manual made a special effort to help learn the language: each example can be visualized in the playground, where it can be changed, and converted to JS.

Download the compiler as an add-in for Visual Studio. It can be obtained under Node with the command: npm install -g typescrit.
The language is supported in addition to VS by Eclipse and various commercial EDIs.

Playground. Check the live translation of the TypeScript program into JavaScript.

Programming and dated languages - Asm.js- - BASIC- C- -C++ # C- - Darth-Eiffel - Guo- --JavaJavaScript--Julia PascalPHP- - - Python- - Prolog RubyLa ScalaScriptolSwift TypeScriptHTMLVasmXMLXAML SQL