Monday 4 September 2017

TypeScript : An Introduction

TYPESCRIPT INTRODUCTION

Typescript is the sexiest JavaScript!

Typescript gives the privilege to write the code like JAVA or C and compiles into JavaScript code on the fly both on the server side and client side.

It was becoming difficult to build large-scale applications using JS, there was a demand for a language which can ease the development of components in JS. Thus Typescript Originated! It was first made public in October 2012 after two years of internal development at Microsoft.

venn-es5-es6-typescript

Typescript is a  strict superset of JavaScript (ECMAScript 5 ). A JavaScript program is a valid Typescript program.
With Typescript it is possible to use existing JavaScript code along with its libraries.
Typescript comes with many advantages over JavaScript :
  • It is purely Object Oriented Programming having support for adding classes and modules
  • Modules in Typescript are very useful in organizing code with which large scale application development becomes easy.
  • Can be used for client side and server side development
  • It includes Static Type Checking
  • Has a “compiler” for converting the code into JavaScript
  • It follows EcmaScript 6 proposals



Below is a code snippet showing the difference between a Typescript and a JavaScript code :
Typescript-and-the-Javascript-code

Angular 2 uses Typescript as the major tool for application development as it provides advanced autocompletion, navigation, and refactoring which is very much essential in developing large scale apps . Moreover it attracts many object oriented programmers to write large scale appliation codes !
Other than angular 2 many other technologies also take benefit of Typescript :

  • React
  • Node JS (Express + MongoDB + Typescript)
  • ASP .Net Core
  • React Native
  • Vue.js
  • Glimmer (component library with Typescript support)
  • WeChat
  • Dojo 2
  • Knokout