The beta was published on June 26. The production version is slated for release in August, according to the roadmap for the platform.
As proposed, TypeScript 4.0 boosts speed in the
build mode, with the caching of semantic diagnostics in the builder written to the disk with
.tsbuildinfo, to benefit the next incremental build. This is intended to fix a situation in which compiling a program after a previous compile with errors under
--incremental would be very slow when using the
dependencies field. Information from these packages is used to improve auto-imports while not changing anything like type-checking.
Other capabilities in TypeScript 4.0 include:
- Variadic tuple types provide the ability for tuple types to have spreads of generic types that can be replaced with actual elements through type instantiation. Spreads in tuple type syntax now can be generic. Thus, higher-order operations on tuples and arrays can be represented even if the actual types being operated over are not known. Also, spread elements can occur anywhere in a tuple, not just at the end. Version 4.0 also improves the inference process for rest parameters and rest tuple elements. Variadic tuple types enable new patterns, especially around function composition.
- Tuple types now can provide labels, for ease of use.
- Control flow analysis now can be used to determine the types of properties in classes when
- A proposal to add three new assignment operators,
??=, is supported as a coding enhancement.
- The type of
catchclause variables can be specified as
unknownbeing safer than
anybecause it reminds developers that they must perform type-checking before operating on their values.
- For JSX factories, users can customize the fragment factory through a new
jsxFragmentFactoryoption. A fragment is a type of JSX element for returning multiple child elements.
- In a breaking change, operands for
deletemust be optional. Also, the usage of TypeScript’s node factory has been deprecated.
The TypeScript 4.0 beta can be accessed through NuGet or via NPM with the following command:
npm install typescript@beta. TypeScript 4.0 follows the TypeScript 3.9 release published in May.
Copyright © 2020 IDG Communications, Inc.