7 Obvious Reasons to Use TypeScript

Why using TypeScript over vanilla JavaScript is a better choice in Enterprise Software Development

Md Kamaruzzaman
May 30 · 9 min read
Image for post
Image for post
Photo by Ales Nesetril on Unsplash

Brendan Eich originally developed JavaScript as a simple language for manipulating the Browser’s DOM. Over the years, JavaScript has grown into a powerful, multi-paradigm programming language and the lingua franca of the Web. Earlier versions of JavaScript (pre ES5) had many issues to develop large and enterprise-scale software development because of its dynamic nature and language design problems as shown by the following Meme:

To overcome the shortcomings of JavaScript, Google developed a toolset GWT as early as 2006, which compiles Java to JavaScript. Over the years, many other programming languages emerged that transpiles to JavaScript: CoffeeScript, flow, ClojureScript, Scala.js, Dart, TypeScript, Elm, PureScript.

Among those languages, one stands out head and shoulder above others: TypeScript. Microsoft developed TypeScript in 2014 as “Typed Superset of JavaScript,” which gained skyrocketing popularity. Not everyone loves TypeScript. Many JavaScript developers disliked the Typed nature of TypeScript and think modern JavaScript (post ES5) is good enough for Enterprise-grade and large scale Web development.

I have worked with both JavaScript (in Node.js projects) and TypeScript (in Angular projects). Both of them are excellent programming languages. In a previous post regarding mainstream programming languages, I have put JavaScript as the second most demanding mainstream language:

In another post about modern programming languages, I have put TypeScript as the 4th most demanding modern programming language:

Here I want to describe why using TypeScript over vanilla JavaScript is a better choice, especially for large-scale and enterprise software development. This post is not about describing what TypeScript or JavaScript is, and I assume the readers already know about TypeScript and JavaScript.


It is Typed

As mentioned on its official website, TypeScript is JavaScript with added Type annotation. Now, the question may arise whether Statically Typed language is better than the dynamically Typed language. The answer is: it depends. Because of its Type System, TypeScript has following advantages over JavaScript:

  • It gives Compile-time safety
  • It is Easier to Understand
  • It is faster to implement using modern IDE’s (code auto-completion, more natural search).
  • It is easier to refactor
  • It gives better performance

On the other hand, JavaScript has the following advantages over TypeScript for its dynamic Type:

  • No additional compiling step
  • Concise and succinct code
  • No need to learn the “extra” Type system
  • With “duck” typing, easier to hack
  • Easier to write higher-level abstraction without a Type system

Now whether TypeScript or JavaScript is more productive is a close call and will depend more on the developer. For a smaller code-base, JavaScript can have the edge over TypeScript. But for a large code-base, which is common in business applications, TypeScript will have the edge due to its Type annotation. Also, nowadays, most of the developers know several languages (including some typed languages) and use modern IDE. If someone already knows a Typed language and JavaScript, then learning TypeScript needs little effort, and they can have all the advantages of Typed language.

It has excellent language design

There are many other Typed JavaScript languages. What makes TypeScript unique is the language design. Anders Hejlsberg is a veteran programming language designer who has previously developed programming languages like Delphi, Turbo Pascal, and C#. He has used all his experience to design TypeScript as a clean, elegant programming language.

Most of the other programming languages first design their Type system and then use it. But TypeScript designers first looked after the JavaScript use cases and later developed the Type system so that it retrofits the JavaScript use cases. Also, unlike the C-family languages, which uses nominal types, TypeScript uses Structural Types.

Also, TypeScript uses some of the most advanced type systems like Union Types, Intersection Types, Differentiating Types, Nullable Types, Conditional Types. Here is the official documentation of TypeScript’s advanced types. Like many other modern languages, it also offers Type Inference.

In terms of language design, it is comparable to other modern languages like Kotlin, Go, Rust.

It gives development scaling

By development scaling, I want to mean the productivity of the teams will remain high even when more teams are added to the project.

Usually, a group of excellent JavaScript developers working on a Project may not need TypeScript. But if many teams are working on the same JavaScript Project, the productivity will fall.

Due to its Type system, elegant language design, IDE support: TypeScript will give better development scaling compared to JavaScript in a large project. It is no wonder that the official slogan of TypeScript is: “JavaScript that Scales.” As development scaling is a significant factor in today’s Software development industry, many large corporations and large open-source projects are increasingly using TypeScript.

Developers love it

Anders Hejlsberg and the TypeScript team of Microsoft has done an excellent Job to design TypeScript as a pragmatic, modern, elegant programming language. Their hard work is vindicated as the software development community loves TypeScript. I once have introduced TypeScript to a group of pure JavaScript developers who only worked with JavaScript until that point and did not know any Typed programming language. Initially, I was worried whether they would like it working with TypeScript. After the initial learning phase (several weeks), all of them expressed their love and satisfaction with TypeScript and wanted to stick with it rather than going back to JavaScript.

In the Stackoverflow Developer Survey 2019, TypeScript has ranked joint second with Python in the most beloved language category:

Image for post
Image for post

It is popular and going strong

A language can have excellent features, but it does not mean that the language will be popular. Also, some languages gain popularity and instant hit (like Scala, CoffeeScript) but then later fade away.

For organizations and companies, choosing a new language is always a tricky question. What happens if the language will fade away in popularity in 5 years? What we will do with our production code base if we cannot hire new developers? For this reasons, shifting to a new programming language always need special considerations and careful observations.

Fortunately for TypeScript, the enterprises should not need to worry as it is already a trendy language. According to the GitHub Contributions, TypeScript has entered the Top 10 List (ranked 7th) :

Image for post
Image for post
Source: Octoverse

It is also one of the fastest-growing languages and ranked fifth with a 161% increase in adoption last year:

Image for post
Image for post
Source: Octoverse

Another critical factor of TypeScript is that it is seeing increasing adoption in the industry over the years. With almost 12 million downloads in every week, it is one of the fastest adapted Technology in JavaScript landscape:

It is also the most popular programming language that transpiles to JavaScript as shown by “The State of JavaScript, 2019” survey:

It is Open Source and Backed by Microsoft

Microsoft had first created TypeScript in 2014. As Google was also planning to develop a similar Typed JavaScript at that time, they collaborated with the Microsoft team and worked together for the development of TypeScript. Thus from the very beginning, two of the “Big Four” Tech companies are backing TypeScript. It is also Open Source with a very permissive Apache 2.0 license. Currently, TypeScript is supported by many other large corporations and software development communities.

With 60k+ GitHub stars and 30k commits, it is one of the most active GitHub project:

Image for post
Image for post
Source: GitHub

I know many people have reservations regarding Microsoft for its history. But Microsoft in 2020 is a different company with different philosophies compared to Microsoft in, e.g., the 2000s. Today, Microsoft is the largest open-source contributor and has even joined the Linux Foundation. Also, the most popular Open Source IDE VSCode is developed by Microsoft. So, there is no reason not to use TypeScript as Microsoft develops it.

It is Superset of JavaScript

Another killer feature of TypeScript is that it is Typed JavaScript with some extra features which are not yet in JavaScript but may come in the future. Here TypeScript differentiates with other languages like CoffeeScript, which wanted to create a new language.

Also, when TypeScript first added Class and Module support, JavaScript did not have them. Once JavaScript incorporated them, TypeScript has aligned itself with JavaScript. Thus, TypeScript looks at the ECMAScript specification, and TC39 committee and implements Proposal, Draft, or Candidate features ahead of JavaScript. Most of the time, this feature later comes in JavaScript. So, learning these features is in no way a waste of time. For example, here are some TypeScript features what are not yet in JavaScript:

  • Optional Chaining
  • Nullish Coalescing
  • Enum Type
  • ECMAScript Private Fields
  • Top-Level await

Thus with a three months release cycle, TypeScript can add proposed ECMAScript features much faster than official JavaScript.

Popular frameworks and big companies are using it

Angular is the first top-level JavaScript framework that has used TypeScript. Recently, Evan You (the creator of Vue.js) has stated that the Vue.js is going through a major overhaul in version 3.0 and they will use TypeScript for Vue.js 3.0:

Image for post
Image for post
Source: Vue.js Roadmap

In his opinion, TypeScript gives significant advantages over JavaScript to maintain a large, sophisticated code base like Vue.js in a clean way. Even the Ember.js core team has moved to TypeScript in their revamped release Ember Octane. Another hot JavaScript framework Svelte also used TypeScript. Very few people have more experience with JavaScript than the creator of Node.js Ryan Dahl. In his new JavaScript and TypeScript runtime Engine Deno.js, Ryan Dahl has used TypeScript over JavaScript, which is a massive statement in favor of TypeScript:

Image for post
Image for post
Source: GitHub

As created by Microsoft and supported by Google during the early stage of development, TypeScript is hugely adapted and backed by large companies. Also, due to its Enterprise friendly features (developer productivity, typed, scalable, elegant, IDE support), which are very valuable in writing and maintaining large code-base, more and more large companies are using TypeScript. Here is an excellent blog describing why Lyft has moved to TypeScript.

Similar articles:


A note In Plain English

Did you know that we have four publications and a YouTube channel? You can find all of this from our homepage at plainenglish.io — show some love by giving our publications a follow and subscribing to our YouTube channel!

JavaScript In Plain English

New JavaScript + Web Development articles every day.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store