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:
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.
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.
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.
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.
As this release introduces few updates in inference, it does come with some breaking changes:
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