Now Reading
Microsoft Releases TypeScript 4.0 With Speed Boosting Features

Microsoft Releases TypeScript 4.0 With Speed Boosting Features

Ambika Choudhury
W3Schools

Microsoft recently announced the availability of TypeScript version 4.0. The developers at the tech giant claimed that this version of the language represents the next generation of TypeScript with more expressivity, productivity as well as scalability. 

Developed by the tech giant, TypeScript is an open-source programming language that is built on top of JavaScript by adding syntax for static type definitions. The types in this language provide a way to describe the shape of an object, providing better documentation as well as allowing TypeScript to validate that the code is working correctly.

According to the latest Stack Overflow Developers survey 2020, it secured the second position as the most loved language and  9th position among 25 programming languages as the most commonly used programming language by the developers. In one of our articles, we discussed how TypeScript weighs over other programming languages.



It is one of the fastest-growing programming languages among the developers. The motive behind this language is that while writing down the types of values and where they are used, developers can use TypeScript to type-check the code and let them know about mistakes before they run the code. TypeScript compiler can be used to strip away types from the code, leaving them with clean, readable JavaScript that runs anywhere.  

In the present scenario, TypeScript is a core part of many developer’s JavaScript stack. The language adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host and on any operating systems.   

The program manager of TypeScript, Daniel Rosenwasser, said in a blog post, “In our past two major versions, we looked back at some highlights that shined over the years. For TypeScript 4.0, we’re going to keep up that tradition.”

What’s New?

Based on the feedback by the developer’s community, TypeScript 4.0 includes many intuitive features that are focussed on boosting the performance of this language. Some of them are mentioned below-

Speed Improvements in build mode with –noEmitOnError

According to Rosenwasser, previously, compiling a program after a previous compile with errors under incremental would result in extremely slow performance when using the –noEmitOnError flag. The reason is, none of the information from the last compilation would be cached in a .tsbuildinfo file based on the –noEmitOnError flag.

But now TypeScript 4.0 changes this. The new update provides a great speed boost in these scenarios, and in turn, improves the build mode scenarios, which imply both –incremental and –noEmitOnError.

Inference Process

TypeScript 4.0 improves the inference process for rest parameters and rest tuple elements. Along with the inference improvements, TypeScript 4.0 brings two fundamental changes in order to make easy typing of concat and tail JavaScript functions. 

The first change is that the spreads in tuple type syntax can now be generic. This means that developers can now represent higher-order operations on tuples and arrays even when they don’t know the actual types they are operating over. 

The second change is that the rest elements can occur anywhere in a tuple and not just at the end. Previously, TypeScript would issue an error, such as “A rest element must be last in a tuple type”. But with TypeScript 4.0, this restriction is now relaxed.

Variadic Tuple Types

According to Rosenwasser, variadic tuple types enable a lot of new exciting patterns, especially around function composition. This feature is expected to perform a better job in type-checking JavaScript’s built-in bind method. 

See Also
microsoft-github-linkedin

Labelled Tuple Elements

The lack of labels on tuple positions can make them harder to use as well as harder to communicate the intent. That is why in TypeScript 4.0, tuples types can now provide labels, which will deepen the connection between parameter lists and tuple types. Overall, labelled tuples are handy when taking advantage of patterns around tuples and argument lists, along with implementing overloads in a type-safe way.

unknown on catch Clause Bindings

TypeScript has ‘type any’ by default which can sometimes cause undesirable behaviour if one is trying to prevent more errors in the error-handling code. Version 4.0 will

now let a user specify the type of catch clause variables as unknown instead. unknown is safer than any because it reminds the developers that they need to perform some sorts of type-checks before operating on the values.

Wrapping Up

Besides the features mentioned above, there are several other features added in version 4.0, such as custom JSX factories, editor improvements and more. As a cherry on the top, the TypeScript website has recently been rewritten from the ground up which was rolled out early this month. 

For those who have not tried their hands on TypeScript yet, Typescript Playground is a website exclusively made for them. Playground provides you with a chance to write, share and learn TypeScript. 

Rosenwasser has also mentioned that the upcoming version of TypeScript, i.e. TypeScript 4.1, is around the corner. The beta version of 4.1 is going to be released in September, while the final release will land in November this year. 

What Do You Think?

If you loved this story, do join our Telegram Community.


Also, you can write for us and be one of the 500+ experts who have contributed stories at AIM. Share your nominations here.

Copyright Analytics India Magazine Pvt Ltd

Scroll To Top