TypeScript: Making JavaScript more secure
Provided by Microsoft, compiled into JavaScript, this language became the most widely used in projects hosted on GitHub in 2025.
The language was created by Anders Hejlsberg who is also the author of Turbo Pascal and C#.
Unlike Google's Dart, which offers the same features but aims to replace JavaScript in browsers, TypeScript is a frontend tool designed to make the programmer's job easier.
It is a superset of JavaScript: we can use a code written in the latter, make a TypeScript source and add types to variables.
Typescript is used in production with always positive returns, because it greatly improves productivity, and one never want to return to JavaScript. The only significant drawback is the slow compilation on big projects. It is the programming language of Angular 2 (from Google).
The compiler is open source under the Apache license and built with Node.js and Jake, a kind of Make for projects designed to JavaScript, where makefiles are replaced by jakefiles. The source code itself is written in TypeScript, and converted into a single file, TypescriptServices.js (the compiler), so it uses the V8 interpreter from Google!
The executable code of the compiler is provided in Visual Studio or available as npm module
In 2025, the compiler was rewritten in the Go language, resulting in a tenfold increase in compilation speed..

The playground shows how the TypeScript code becomes JavaScript. Since ECMAScript 6 (2015) the JS code is the same.
Static types
The syntax var x: boolean can annoy at first. Writing number x or bool x as in C would have been simpler. Following this logic, instead of writing class x why not write definition x: class?
But this is nevertheless justified here by the optional types: we can write var x and have a dynamic variable whose type can change during processing, or add a static type. The type is clearly an option, and this syntax is in line with Asm.js or Julia.
The language implements the following types:
- boolean.
- number.
- string.
- list: Converted to array, but with a type in option to be converted to typed array.
- enum: Convert to array or constants for now.
- const enum (1.4). A const with several properties.
- any: generic type that supports all values.
- void: for return of functions.
- undefined.
Functions
A function can have generic arguments by overload or through union.
Example of union:
function(s:string | string[])
Classes and interfaces
The syntax for declaring a class is similar to that of ECMAScript 6 and in fact most of programming languages. We define the constructor with the reserved word constructor, and this is added to reference an attribute in the class.
For example:
class car {
passengers = 4;
constructor(persons : number) {
this.passengers = persons;
}
mymethod(message : string) {
console.log(message);
}
}
var mycar = new car(2);
Inheritance is done with the extends keyword:
class car extends vehicle { ... }
The constructor may call the constructor of the inherited class with super(...).
Attributes are public by default, we need only a private keyword to declare a member as private.
The reserved word static can be applied to class members to share values assigned between all inherited classes.
Inheritance is translated into JavaScript with prototypes while other elements are used only to control by the compiler and are not converted. It is probable that the language will evolve to a more accurate translation when ECMAScript will be widely implemented.
Classes may be associated with interfaces. Example:
class motor extends car {
power : number;
}
interface car {
passengers : number;
}
var mycar : car = { passengers : 4, power : 300 };
TypeScript therefore has both inheritance and composition, that Go and Dart for example do not offer. Unfortunately it does not seem more intended for ES 6 and may force you to stay on TypeScript if you actually use this feature, because this can be useful for reusability of code.
Other additions
An overview of other language features among the many functions that you will find described in detail with examples in the TypeScript documentation on the website.
- Generics. A mechanism is provided with the syntax <T> that allows multiple dispatch.
- Modules. Functions, variables, classes can be incorporated into a module. The reserved word export permits to make a function usable outside the module. This is similar to what is offered by npm.
- Mixins. By replacing the word reserved extends by implements, inheritance is replaced by composition, one "implements" one or more classes, and they are treated as interfaces! This is equivalent to the trait of other languages. Class methods implemented are not inherited, they must be redefined in the class that integrates them.
- Iterator and generator.
Using TypeScript natively
With Node.js since version 23.6, it's possible to use TypeScript directly without compiling it into JavaScript.
For example:
let y: string;
function test(x: number): string {
return "test " + x;
}
y = test(10);
console.log( y );
Save the code to tscript.ts and run node:
node tscript.ts
Why use typescript?
The advantage of typescript on all the other languages that are compiled into JavaScript is that it is a superset: You can reuse a JS file and include features added in typescript, and then rename the file from .js to.ts.
And when the language introduces new features, they come from ECMAScript 6 and followers, so it remains a superset of JS.
Having typed variable has become crucial with the use of artificial intelligence to generate code. The vast majority of errors come from inappropriate types in assignments or function arguments, and these are detected during compilation of TypeScript code.
Typescript seems indispensable for a large JavaScript project. The code generated is also optimized for JIT interpreters.
External links:
TypeScript. The official site.
The authors of the manual have made a special effort to help learn the language: each example can be viewed in the playground where it can be modified, and is converted into JS.
Download the compiler as add-on to Visual Studio. You can get it as module to Node: npm instal l-g typescript.
The language is supported beside VS by Eclipse and various commercial IDEs.
Playground. Test live translation of a TypeScript program in JavaScript.

