Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon

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

Save for later
  • 3 min read
  • 01 Apr 2019

article-image

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.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime

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.

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

Typescript 3.3 is finally released!

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