TypeScript Introduction

In this TypeScript introduction you will learn what is TypeScript, how its work, how to write object oriented concept like class, interface, generic, enum etc, advantage of TypeScript etc.

TypeScript is a free and open source programming language developed and maintained by Microsoft. TypeScript is a language that adds object-oriented syntactical flavour to JavaScript. TypeScript is designed to fulfil the needs of the JavaScript developers to build more robust and maintainable large JavaScript code. To use TypeScript you need a build process to compile to JavaScript code. Compiled TypeScript files being deployable where a regular JavaScript application would run.

TypeScript is a superset of JavaScript which provides optional static typing, classes, interfaces, enum, generics etc. It enables developers to write class-based object-oriented programming code for JavaScript. TypeScript can be used to develop JavaScript applications for client-side or server-side (Node.js) execution.

TypeScript syntax includes all features of ECMAScript 2015, which includes classes and modules, and provides the ability to translate these features into ECMAScript 3 compliant code. That means you can use features of ES2015 and beyond, like modules, lambda functions, classes, the spread operator and many more today.

Advantages of TypeScript

  • Enable developer to write large maintainable JavaScript code easy.
  • TypeScript is adopted into major projects like AngularJS 2.0 and Ionic Framework 2.0.
  • Enable developer to express object oriented concepts in standard way by including inheritance, module, class etc.
  • It supports all features of ECMAScript 2015.
  • TypeScript provides command line TSC compiler to manually compile your code.
  • Microsoft Visual Studio now supports "compile on save" for TypeScript files.
  • In built text editor provided by Microsoft Visual Studio 2013 Update 2 and later versions.
  • TypeScript is open source and available on GitHub.
  • TypeScript compiler is implemented in TypeScript and can be used in any JavaScript host.

TypeScript Example

class Customer {
	Name : string;
	constructor (firstName: string, lastName: string)
		this.Name = firstName + "  " + lastName;
		return "Hello, " + this.Name;

let cust = new Customer("Jimi","Scott");

let button = document.createElement('button');
button.textContent = "Display Full Name";
button.onclick = function() {

Try it Yourself