Course Banner

TypeScript Introduction

TypeScript is Javascript’s superset which is a product of Microsoft.It was designed by Anders Hejlsberg (designer of C#) at Microsoft It’s an optional statically typed language which is object oriented also. It supports class, object,inheritance and interfaces also.

Why TypeScript?

Features of TypeScript

TypeScript and JavaScript. TypeScript starts with JavaScript and ends with JavaScript. Typescript basic building blocks of coding are based on JavaScript structure. Hence, you only need to know JavaScript to use TypeScript. All TypeScript code is converted into its JavaScript equivalent for the purpose of execution.

1. TypeScript supports other JS libraries.

Once the Typescript code is compiled, it can be used along with any javascript code. TypeScript-generated JavaScript can reuse all of the existing JavaScript frameworks, tools, and libraries.
JavaScript is TypeScript. So, any valid .js file can be renamed to .ts and compiled with other TypeScript files.

2. TypeScript is portable.

TypeScript can be used across browsers, devices, and operating systems. So, any operating system or environment that supports javascript, can run typescript also. Unlike its counterparts, for TypeScript there is no requirement of dedicated VM (Virtual Machine) or a specific runtime environment to execute.

TypeScript and ECMAScript

ECMAScript is a Standard for all scripting languages.. The current version ECMAScript is 6. The code Name for ECMAScript 6 is called "Harmony". TypeScript is also based on with the ECMAScript 6 specification. TypeScript gets its fundamental language pattern from the ECMAScript5 specification. While working with Typescript, you will see that it has javascript features but unlike Javascript, its object-oriented. And its Modules and Object oriented pattern are based on EcmaScript 6 specification. But, TypeScript has few features like generics and type annotations which is not a part of the EcmaScript6 specification.

ECMA Script in nutshell

  • ECMAScript is a Standard for a scripting languages.
  • Languages like Javascript and Jscript are in the line with ECMAScript standard.
  • ECMA Standard is based on several originating technologies, the most well known being JavaScript (Netscape) and JScript (Microsoft).
  • ECMA stands for European Computer Manufacturer’s Association.

Why Use TypeScript?

TypeScript is far better than its parallel languages like CoffeeScript and Dart programming languages in a way that TypeScript is extended JavaScript. On the other hand, languages like Dart, CoffeeScript are new languages in themselves and require language-specific execution environment. Also, the developer has to learn its syntax. But in case of Typescript, knowledge of Javascript is enough.

The benefits of TypeScript include −

Compilation − As you know Javascript is an interpreted language which runs on browser. Javascript code does not require any compilation.So, any mistake in the code, it becomes a daunting task to find the bug and fix it.yes browser's ‘console’ is helpful to some extent but sometimes that also is not that much handy to debug the code. The TypeScript , on the other hand has great feature called transpiler which help in run time error checking. TypeScript first compiles the code and shows error, if any.

Strong Static Typing − If you have worked on javascript, you might be aware that it's a loosely typed language. Its called Loosely typed language because it does not require to data type while declaring the variable. On the other hand TypeScript is a static typing language like JAVA. But this static typing is optional also. The benefit is that with this we can better type check with the coding.

Object Oriented : TypeScript supports Object Oriented Programming Concepts like classes, interfaces, inheritance, etc. So, if you are from Object Oriented programing coding background, it will be easy to understand and grasp this language.

Ad Image

The Best Websites for Free Online Courses, Certificates, Degrees, and Educational Resources

take $10 0ff for new users