Should You Learn Typescript as a JavaScript Developer?

Should You Learn Typescript as a JavaScript Developer?

In the JavaScript universe, there is always a new trend/technology, and these trends are “almost” always innovative.

When the shortcomings of a well-established stack become too inconvenient, alternatives appear and sometimes pass from the status of novelty to that of an unavoidable trend, before being inexorably replaced in their turn.

Here, with the successive appearance of frontend frameworks: jQuery (2006), Backbone.js (2010), React (2013), Vue.js (2014), PolymerJS (2015), Angular (2016)… Some of these technologies have (almost) fallen into oblivion, while others have now become standards in web development.

Among these trends, TypeScript is certainly one of those technologies that raise the most questions.

In short: YES, you should learn TypeScript as a JavaScript developer!

Now, let’s get to the explanations…

​TypeScript: What it is and why should I care?

TypeScript is a programming language whose first public version (0.8) was released in October 2012 after two years of internal development at Microsoft.

Specifically, TypeScript is a strict syntactic superset of JavaScript: any valid JS code can be used within TypeScript, and any TypeScript code can be interpreted by any web browser or JavaScript engine after being transpiled to JS.

It can be used on both the client side and server side with NodeJS.

The creation of TypeScript was due to the confrontation of Microsoft with the shortcomings of JavaScript for the development of large-scale complex applications, both at Microsoft and at their external customers.

The solution aims to facilitate the development of JS components by adding new features to JavaScript: optional static typing of variables and functions, classes and interfaces, import of modules, etc.

By default, TypeScript compiles to ECMAScript 5 (JS version from 2009, the current standard supported by modern browsers) but can also target ECMAScript 3 (1999 version supported by all browsers) or ECMAScript 2015 (version 6, not supported by Internet Explorer).

Used by default in many frameworks such as Angular and NestJS, TypeScript is increasingly present within the JS ecosystem so much so that it was at the origin of more than 7% of pull requests on Github in 2020 (compared to 18.84% for JavaScript and above PHP or C) according to GitHub 2.0 :

typecript trend
GitHub language usage from 2014-2022

​What are the benefits of learning TypeScript?

TypeScript is a language whose mastery is increasingly sought after by companies. This growing popularity is easily explained by the considerable advantages that TypeScript brings.

​TypeScript makes development easier and improves the developer experience

The main feature that TypeScript brings to JavaScript is support for static typing of variables and functions. If you are a JS developer who has never touched other languages, you may not be familiar with this important notion in programming.

“Typing,” tells a program what type of values ​​a variable or function can accept. Some languages ​​like JavaScript or Python have dynamic typing: the type of each variable is known only when the program is run.

Conversely, some languages ​​like Java or C++ have static typing: where the type of each variable is defined in the code and is therefore known when the code is compiled.

If a value of a certain type is assigned to a variable (or as an argument of a function) defined as being of another type, an error will be generated during compilation and the program cannot be executed.

There are many different types, the most common of which in programming are: Number ( int for integer, float for decimal), a Character string (string), Table (array), Boolean (Boolean)… Some do not exist in TypeScript, but this language offers other advanced types such as Any & Unknown, Void, or Never. You can read more about these types in the TypeScript documentation.

While JavaScript only supports dynamic typing, TypeScript allows you to optionally use static typing.

Your program then knows, before it is executed, which type of values ​​are accepted for which variables.

No need to waste time digging through many files or in the docs of a library trying to find out which parameters a particular function accepts or which fields are present in a particular object: your TypeScript-compatible IDE (Visual Studio, WebStorm, Eclipse, Atom…) will let you know as you write your code.

This kind of self-integrated and always up-to-date documentation of the latest changes speeds up and facilitates the development of complex applications where many developers are called upon to collaborate and their debugging.

A study also shows that 15% of all JavaScript bugs can be detected by TypeScript.

​TypeScript will make you a better developer

Although optional, the static typing of variables and functions supported by TypeScript allows you to define specific data structures early in your app development.

This imposes a framework and rules that will have to be respected and thus pushes for a more coherent design of the application as a whole while limiting the risks of breaking by making significant changes in the code.

Learning TypeScript is also a great way to nurture yourself with programming concepts you may not have known before. Beyond types, TypeScript also uses other notions:

Already present in other statically typed programming languages ​​such as C++ or Java, becoming familiar with these concepts will make it easier for you to tackle other languages ​​in the future if you wish.

​TypeScript is easy to learn and has an active community

TypeScript is used and supported by the most advanced tech companies such as Microsoft, Google, Airbnb, Shopify, Adobe, and Mozilla.

Since these companies are obviously used to deploying huge, extremely complex applications on a very large scale, one can only be convinced of TypeScript’s ability to guarantee scalability, optimal reliability, and performance.

The adoption of TypeScript by these technology leaders has helped popularize this language and federated a large and very active open-source community that publishes a large number of educational resources and tools.

GitHub Octoverse also places TypeScript in 5th position among the languages ​​with the fastest growth between 2018 and 2019 (161%) ahead of Python (151%) and Go (147%).

Evolution of
growth of typescript

Since TypeScript is a strict syntactical superset of JavaScript, capable of compiling any valid JavaScript code, you can easily and gradually include it in your current JS projects without having to rewrite all your code. You can find a guide on migrating from JavaScript to TypeScript here.

For corporate projects, Microsoft has even published a guide to switching to TypeScript discreetly without anyone noticing, and therefore without having to convince your colleagues.

​TypeScript does not fix all problems

As you can see, TypeScript is a great solution for facilitating development and communication between developers — but it’s not a miracle solution!

If TypeScript adds many features to JavaScript while keeping its cross-platform compatibility, its creators and contributors have made it a point of honor to respect the non-binding aspect of JS.

Its power and especially its reliability are thus proportional to the rigor with which the developers will use it.

Its use also does not dispense with setting up unit testing and functional testing.

Finally, TypeScript is not a language in its own right and requires a good knowledge of JavaScript to exploit its full potential.

​Is it relevant to learn TypeScript in order to have a better CV?

As we’ve seen; many companies have moved to TypeScript, including the biggest tech leaders. This skill is increasingly demanded by job offers.

For example, about 1100 job postings on Indeed France referred to TypeScript in September 2020, almost as many as those referring to Node.js (about 1200).

Learning TypeScript today is also an opportunity not to be missed: it is still early enough to be in the “ early majority ” and acquire a skill on your CV that will continue to be valued.


Similar Posts