TypeScript Tutorial
TypeScript is a superset of JavaScript that supports the ECMAScript 6 standard (ES6 Tutorial).
TypeScript is a free and open-source programming language developed by Microsoft.
The design goal of TypeScript is to develop large applications. It can be compiled into pure JavaScript, and the compiled JavaScript can run on any browser.
Language Features
TypeScript is an extension of JavaScript that adds features to the language. The added features include:
- Type annotations and compile-time type checking
- Type inference
- Type erasure
- Interfaces
- Enumerations
- Mixins
- Generic programming
- Namespaces
- Tuples
- Await
The following features are backported from ECMA 2015:
- Classes
- Modules
- Arrow syntax for lambda functions
- Optional and default parameters
Differences Between JavaScript and TypeScript
TypeScript is a superset of JavaScript, extending its syntax. Existing JavaScript code can work with TypeScript without any modifications. TypeScript provides compile-time static type checking through type annotations.
TypeScript can process existing JavaScript code and compile only the TypeScript code within it.
First TypeScript Example
The following example demonstrates using TypeScript to output Hello World!
:
Example
const hello: string = "Hello World!";
console.log(hello);