TypeScript 5.5, the latest version of Microsoft’s strongly typed JavaScript variant, has arrived in beta with improvements ranging from performance and size optimizations to regular expression checking.
The TypeScript 5.5 beta was introduced April 25 and can be accessed through Nuget or the following command: npm -D typescript@beta
. A release candidate is due June 4, and the final release is planned for June 18.
TypeScript 5.5 has a long a list of improvements. For performance and size, monomorphization work has been done for the language service and public API. With monomorphism, the editor experience and build tools using the TypeScript API will get faster, TypeScript’s authors said. This was the same work previously done for Node and Symbol objects in TypeScript 5.0 to ensure they had a consistent set of properties with a consistent initialization order.
TypeScript 5.5 also features a significant reduction in overall package size. The disk footprint has been reduced from 30.2 MB to 20.4 MB, and the packed size from 5.5 MB to 3.7 MB. As part of work to enable isolatedDeclarations
, Microsoft has improved how often TypeScript can directly copy input source code when producing declaration files.
TypeScript 5.5 introduces basic syntax checking on regular expressions. Until now, TypeScript typically skipped over most regular expressions in code, because regular expressions technically have an extensible grammar and TypeScript never made an effort to compile regular expressions to earlier versions of JavaScript. This meant common problems would go undiscovered in regular expressions.
With TypeScript 5.5, TypeScript will now infer that a function returns a type predicate under certain conditions. And with control flow narrowing for constant indexed accesses, TypeScript now is able to narrow expressions in for obj[key]
when both obj
and key
are effectively constant.
TypeScript 5.5 makes API consumption of ECMAScript modules easier. Previously, if a developer was writing an ECMAScript module in Node.js, named imports were not available from the typescript
package. This has been fixed. TypeScript also now supports a new @import
comment tag that has the same syntax as ECMAScript imports.
TypeScript 5.5 also adds a transpileDeclaration
API, which is designed to generate a single declaration file based on input source text. The API is similar to transpileModule
for compiling a single file of TypeScript code.
TypeScript 5.5 follows TypeScript 5.4, which became generally available in March and brought preserved narrowing within function closures.
Copyright © 2024 IDG Communications, Inc.