Category: TypeScript
-
Learning TypeScript Part 5- Functions
Functions Just as in JavaScript functions can be created both as a named function or as an anonymous function. Similar to JavaScript TypeScript also captures variables. Contextual Typing As you can see in the above example TypeScript compiler can figure out the type if you have types on one side of the equation but not the other.…
-
Learning TypeScript Part 4 – Classes
Classes Traditional JavaScript uses prototype based inheritance as the basic means of building up reusable components. but this is bit different from the object oriented approach to which we are most accustomed where classes inherit functionality and objects built from these classes. Starting ES6 JavaScript programmers will be able to build their applications using this object…
-
Learning TypeScript Part 3 – Interfaces
Interfaces Interfaces are the most flexible way of describing types in TypeScript language. The only job of an interface in TypeScript is to describe a type. While classes and functions will deal with implementation. To define an interface use the keyword interface. Roles of Interfaces Describing an Object Describing an Indexable Object Ensuring Class instance Shape…
-
Learning TypeScript Part 2 -Variables
let and const are two new keywords introduced in the ECMAScript 6 (ES6, a.k.a. ES 2015) . Since TypeScript is the superscript of JavaScript the uses of let and const are already accessible in the language. let is similar to var but it helps to avoid some of the common problems with var const is similar to…
-
Learning TypeScript Part 1 – Getting Started
Introduction Typescript is a open sourced programming language developed by Microsoft. It is a Superset of Javascript and it compiles down to plain Javascript. Typescript offers support for the latest and evolving Javascript features including ECMAScript2015 and future proposals like async. Why Typescript? Typescript provides a way to add optional static typing to our Javascript code. It…