Blazingly Fast JavaScript Development

Blazingly Fast JavaScript Development

<strong>Originally published by </strong><a href="" target="_blank">Mohammad Nadeem</a>&nbsp;<strong> </strong><em>at&nbsp;</em><a href="" target="_blank"><em>D</em>zone</a> <em>on </em>&nbsp;Apr. 18, 19

Level up your JavaScript development, and see why TypeScript is so awesome.

I have been trying to keep myself out of UI Development for years until recently with the emergence of Microsoft TypeScript. Developing UI elements with TypeScript is such a breeze that I no longer hit my keyboard too hard and my colleagues are no longer afraid to approach my desk during UI development. Most importantly, I spend more time with my family rather than countless late nights in the office trying to solve an unknown mystery.

Kudos to Microsoft for understanding developer frustrations and filling the long-standing void in JavaScript.

Why TypeScript?

Here are a couple of reasons that this appeals to me.

Object-Oriented Support

One of the main goals of TypeScript is to make it as compatible as possible to ECMAScript 6, hence it supports most (if not all) of the object-oriented concepts/constructs, especially classes, interfaces, modules, generics, static typing, etc. The following code snippet demonstrates most of the concepts. It looks more natural and closer to what an object oriented developer would imagine. This is a good point about typescript in that it borrows most of the concepts and syntax from existing languages, hence the reduced learning curve.

Here is the JavaScript equivalent, showing why it's cause so much commotion among object-oriented developers (example: Java developer).

IDE Support

Most of the IDEs (Eclipse, WebStorm, and Visual Studio) have support for TypeScript, either built-in (Visual Studio) or as a plugin. All of which makes life easier since the IDE acts as the enforcer and guides developers as needed.

Build Tool Support

All major JavaScript build tools Grunt, Gulp and Brunch have TypeScript support. In fact, the example source code demonstrates how we can marry Grunt and TypeScript together very easily.

Syntactic Sugars

Most prominent is the Arrow function or Lambda expressions. Every JavaScript developer has experienced losing the this object while running functions asynchronously, especially in callbacks. Suddenly you find your this** **object changed by something unforeseen, and as a result you end up nodding your head the whole night in front of your monitor. A simple work around is to preserve the this object in some other variable, for example:

The equivalent TypeScript code would be:

External Library Integration

In the above example, you must be wondering, where is CanvasRenderingContext2D defined? This is where type definition(.d.ts) files comes into the picture. Typescript has a definition for every core JavaScript feature/functionality.

The million dollar question: What about the external libraries (jQuery, Backbone, Jasmine, AngularJS, etc.)? It can be defined based on the functionality it provides and that is why the Definitely Typed repository exists. If you explore this repository you will find the d.ts for almost everything you can think of. If for some reason it does not exist, it can be created easily.

TypeScript Alternatives

There is no shortage of languages that compile to JavaScript. CoffeeScript is perhaps the best known example of one of these languages. TypeScript is just one of the many languages that compile to JavaScript, and some of the other popular options are:

  • Google Traceur: Compiles EC6 (Syntactic niceties including class, module, arrow functions, promises, default parameters, etc.) to EC5 JavaScript.
  • Google Dart: Completely new language to address JavaScript issues, cleans up its semantics, and adds static types and class based and object oriented features without being dogmatic.
  • CoffeeScript: Neater syntax which is based on other dynamic languages, thereby making it easier to write.

    Applications Using TypeScript

  • Office365 and Visual Studio Online use TypeScript heavily.
  • UI is written entirely using TypeScript.

    Sample Application

This sample Typescript application is loaded with lots of features and basically demonstrates Typescript feature usage in collaboration with existing libraries and tools.

  • Generics
  • Module, Classes and Interfaces
  • Unit Testing With Mocking and Spying Using Jasmine
  • Grunt Usage
  • Project directory structure organization

Feel free to clone it and play with it. Instructions are provided in the GitHub repository.


We have been witnessing the proliferation of single page applications that are built using JavaScript. It would be a tedious task to maintain/write these applications with just pure JavaScript. Languages that compile to JavaScript (TypeScript, for example) provide good syntactic sugar, structures, and constructs are becoming immensely helpful.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

JavaScript Tutorial: if-else Statement in JavaScript

This JavaScript tutorial is a step by step guide on JavaScript If Else Statements. Learn how to use If Else in javascript and also JavaScript If Else Statements. if-else Statement in JavaScript. JavaScript's conditional statements: if; if-else; nested-if; if-else-if. These statements allow you to control the flow of your program's execution based upon conditions known only during run time.

How to Retrieve full Profile of LinkedIn User using Javascript

I am trying to retrieve the full profile (especially job history and educational qualifications) of a linkedin user via the Javascript (Fetch LinkedIn Data Using JavaScript)

Java vs. JavaScript: Know The Difference

Java vs. JavaScript: Know the Difference, Java vs. JavaScript: What's the Difference? Java vs. JavaScript: Major Similarities and Differences. pros and cons of JavaScript and Java.