News

Microsoft releases TypeScript 3.4 with an update for faster subsequent builds, and more

2 min read

Last week, Daniel Rosenwasser, Program Manager for TypeScript, announced the release of TypeScript 3.4. This release comes with faster subsequent builds with the ‘–incremental’ flag, higher order type inference from generic functions, type-checking for globalThis, and more.

Following are some of the updates in TypeScript 3.4:

Faster subsequent builds

TypeScript 3.4 comes with the ‘–incremental’ flag, which records the project graph from the last compilation. So, when TypeScript is invoked with the ‘–incremental’ flag set to ‘true’, it will check for the least costly way to type-check and emit changes to a project by referring to the saved project graph.

Higher order type inference from generic functions

This release comes with various improvements around inference, one of the main being functions inferring types from other generic functions. At the time of type argument inference, TypeScript will now propagate the type parameters from generic function arguments onto the resulting function type.

Updates in ReadonlyArray and readonly tuples

Now, using read-only array-like types is much easier. This release introduces a new syntax for ReadonlyArray that uses a new readonly modifier for array types:

function foo(arr: readonly string[]) {
arr.slice();        // okay
arr.push("hello!"); // error!
}

TypeScript 3.4 also adds support for readonly tuples. To make a tuple readonly, you just have to prefix it with the readonly keyword.

Type-checking for globalThis

This release supports type-checking ECMAScript’s new globalThis, which is a global variable that refers to the global scope. With globalThis, you can access the global scope that can be used across different environments.

The globalThis variable provides a standard way for accessing the global scope which can be used across different environments.

Breaking changes

As this release introduces few updates in inference, it does come with some breaking changes:

  • TypeScript now uses types that flow into function calls to contextually type function arguments.
  • Now, the type of top-level ‘this’ is typed as ‘typeof globalThis’ instead of ‘any’. As a result, users might get some errors for accessing unknown values on ‘this’ under ‘noImplicitAny’.
  • TypeScript 3.4 correctly measures the variance of types declared with ‘interface’ in all cases. This introduces an observable breaking change for interfaces that used a type parameter only in keyof.

To know the full list of updates in TypeScript 3.4, check out the official announcement.

Read Next

An introduction to TypeScript types for ASP.NET core [Tutorial]

Typescript 3.3 is finally released!

Yarn releases roadmap for Yarn v2 and beyond; moves from Flow to Typescript

Bhagyashree R

Share
Published by
Bhagyashree R

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago