Microsoft has announced the availability of the release candidate (RC) for TypeScript 3.4. TypeScript is Microsoft’s programming language that is a superset of JavaScript.
According to Microsoft, TypeScript 3.4 is the first release that has had an iteration plan that outlines the plans for the release. This is intended to align with its 6-month roadmap for the language, the TypeScript team explained.
The new version includes incremental compilation, which allows it to save information about a project from its last compilation. It will then use that information to determine the most efficient way to type-check and emit changes to a project.
TypeScript 3.4 will also make it easier to use readonly array-like types. It added a new syntax for ReadonlyArray, including a new readonly modifier. It also added additional support for readonly tuples. Any tuple type can be prefixed with the readonly keyword to make it a readonly tuple. In addition, there is a new readonly modifier that can be added to mapped types that will convert array-like types to readonly versions.
Microsoft explained that the readonly modifier is not a general purpose type operator and can only be used on array types and tuple types.
It also introduced a new construct for literal values: const. According to Microsoft, when creating new literal expressions with const assertions, developers can signal to the language not to widen literal types, give readonly properties to object literals, and turn array literals into readonly tuples.
According to Microsoft, TypeScript tends to widen values when declaring a mutable variable or property in order to ensure that things can be assigned later without writing an explicit types. However, since JavaScript properties are mutable by default, the language often widens types undesirably, which results in explicit types being required in certain places. That’s usually okay, but becomes problematic in complex data structures. Microsoft believes that introducing const assertions will solve that problem.
Microsoft also noted that const assertions can only be used on simple literal expressions and const context doesn’t immediately make an expression fully immutable.
TypeScript 3.4 also adds support for type-checking for the new globalThis, which is a global variable that provides a standard way to access the global scope, which is usable across different environments.
In addition, it adds a new refactoring method that converts existing functions to use the “named parameters” pattern.
More information is available here.