
TypeScript 4.0 arrives with performance boosts
TypeScript 4.0, a major upgrade to Microsoft’s popular typed superset of JavaScript, is now available as a production release, with improvements for builds and editing scenarios as well as support for variadic tuple types. The TypeScript 4.0 production release arrived 20 August.
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 --noEmitOnError
flag.
Further, new JavaScript/TypeScript functionality improves editing scenarios in Visual Studio Code and Visual Studio 2017/2019. A new partial editing mode at startup addresses slow startup times, particularly on bigger projects. A smarter auto-imports capability does extra work in editor scenarios to include packages listed in the package.json’s 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
noImplicitAny
is enabled. - A proposal to add three new assignment operators,
&&=,
||=
, and??=
, is supported as a coding enhancement. - The type of
catch
clause variables can be specified asunknown
, withunknown
being safer thanany
because it reminds developers that they must perform type-checking before operating on their values. - For JSX factories, users can customise the fragment factory through a new
jsxFragmentFactory
option. A fragment is a type of JSX element for returning multiple child elements. - In a breaking change, operands for
delete
must be optional. Also, the usage of TypeScript’s node factory has been deprecated.
TypeScript 4.0 can be accessed through NuGet or via NPM with the following command: npm install -D typescript
. TypeScript 4.0 follows the TypeScript 3.9 release published in May.
IDG News Service
Subscribers 0
Fans 0
Followers 0
Followers