Introduction Last updated: 2019-06-01

TypeScript is a scripting language develoepd by Microsoft. It is mainly used in browser's JavaScript engine and NodeJS engine.

History

Here are some important points to note about TypeScript

  1. Developed by Microsoft
  2. First release was in 2012
  3. Stable release is 3.8.3 as of 20 February 2020
  4. TypeScript can provide type safety
  5. TypeScript files have .ts or .tsx extension

Features

Features

TypeScript is a superset of JavaScript. So it contains all features of JavaScript. e.g. Support for classes, modules, and an arrow function syntax (as specified in the ECMAScript 2015 standard) TypeScript has below extra features.

  1. Type annotations and compile-time type checking
  2. Type inference and erasure
  3. Interaces
  4. Enumerated types
  5. Generics
  6. Namespaces
  7. Tuples
  8. Async/await

TypeScript

TypeScript is a superset of JavaScript so It can be used for browser scripting as well as server side scripting (e.g. NodeJS)

  1. TypeScript is superset of JavaScript
  2. TypeScript can be transpiled to JavaScript using default TypeScript Checker or babel
  3. Supports header files for existing js libraries to provide type safety

C#

C# is strongly typed language.

Java

Java is also strongly types language.

Installation

Installation is pretty easy. Execute below command to install the TypeScript

npm install typescript

IDE - Code Editor

You can use Visual Studio Code for writing the TypeScript code.

First Program

Here is our first example.

Typescript

To convert this typescript file to JavaScript file, you need to execute below command. tsc -t ES6 first.ts In above code, we are typescript compiler to convert the first.ts file into JavaScript file compatible with ES7. If you want to run this code, you can use one of the below command. node first.js node first.ts

C# first example

Here is the first example in C#.Net

Java

Here is the first example in Java.