What’s new in TypeScript 3.4

TypeScript 3.4 release candidate promises faster incremental builds, easier read-only arrays, and new support for read-only tuples

The production version of TypeScript 3.4, the latest version of Microsoft’s typed superset of JavaScript, has arrived, with improvements for builds and type-checking.

Where to download TypeScript 

You can download TypeScript through NuGet, or you can get it via NPM:

npm install -g typescript

Current version: The new features in TypeScript 3.4

  • A new compilation flag, --incremental, provides faster subsequent builds. This flag tells TypeScript to save information about the project graph from the last compilation. When TypeScript is again invoked with --incremental, it will use the data to detect the least costly way to type-check and emit project changes.
  • Type-checking is introduced for the ECMAScript globalThis global variable, providing a standard way for accessing the global scope that can be used across different environments.
  • It is now easier to read-only array types, with a new syntax for ReadonlyArray using a Readonly modifier for array types.
  • Support is introduced for read-only tuples; any tuple type can be prefixed with the readonly keyword to make it a read-only tuple.
  • The readonly modifier in a mapped type automatically will convert array-like types to a corresponding read-only array type. 
  • A new construct has been introduced for literal values, const assertions. The syntax is a type assertion with const in place of the type name. When literal expressions are constructed with const assertions, developers can signal that no literal type in that expression should be widened, that object literals get readonly properties, and that array literals become readonly tuples.
  • As a breaking change, the type of top-level this is now typed as typeof globalThis instead of any. As a consequence, developers might receive errors for accessing unknown values on this and noImplicitAny.
  • Another breaking change is that improved inference in TypeScript 3.4 might produce generic functions rather than functions that take and return constants.

To continue reading this article register now