MacMusic  |  PcMusic  |  440 Software  |  440 Forums  |  440TV  |  Zicos
typescript
Recherche

TypeScript 5.8 arrives in beta

vendredi 31 janvier 2025, 00:38 , par InfoWorld
Microsoft has moved TypeScript 5.8 into the beta stage. The new release of the company’s typed superset of JavaScript introduces a limited form of type checking against conditional types in return statements.

The TypeScript 5.8 beta was introduced January 29. To get started with the beta, developers can execute the following command in NPM: npm install -D typescript@beta.

With checked returns for conditional and accessed types, TypeScript now supports a limited form of checking against conditional types in return statements, to avoid type assertions. There is an issue with type assertions in that they can defeat legitimate checks that TypeScript otherwise would perform. With TypeScript 5.8, when a function’s return type is a generic conditional type, TypeScript now will use control flow analysis for generic parameters whose types are used in the conditional type, instantiate the conditional type with the narrowed type of each parameter, and relate against that new type.

Microsoft notes some limits to the feature. Special checking, for instance, only happens when a single parameter is associated with the type being checked against in a conditional type or used as a key in an indexed access type. When using a conditional type, at least two checks must exist, with a terminal branch including never. The parameter’s type has to be generic and be constrained by a union type. Overall, checks will not occur when a specific type is associated with type parameter.

With TypeScript 5.8, developers will not have to wait long for a general availability, according to the release schedule. A release candidate is due February 11 and the final release is due to arrive February 25. TypeScript 5.8 follows the release of TypeScript 5.7 in November, which featured improved error reporting.

Other features planned for TypeScript 5.8 include the following:

Optimizations are being introduced to improve the time to build a program as well as update a program based on a file change in either –-watch mode or editor scenarios. TypeScript now avoids any array allocations that would be involved while normalizing paths. Also, when edits are made that do not fundamentally change the fundamental structure of a project, TypeScript now avoids re-validating options provided to it.

TypeScript adds support for require() of ECMAScript modules in –-module nodenext. When –-module nodenext is enabled, TypeScript will avoid issuing errors on these require() calls to ESM files.

TypeScript introduces a stable –-module node18 flag. Users of Node.js 18 are thus provided with a flag offering a stable point of reference that does not incorporate certain behaviors that are in –-module next. Among these behaviors is that require() of ECMAScript modules is disallowed under node18 but allowed under nodenext.

TypeScript introduces an –-erasableSyntaxOnly flag. When enabled, TypeScript will only allow the use of constructs that can be erased from a file, and will issue an error if any constructs are encountered that cannot be erased.

Node.js 22 no longer accepts import assertions using the assert syntax. And when --module nodenext is enabled in TypeScript 5.8, TypeScript issues an error if it encounters an import assertion.
https://www.infoworld.com/article/3813778/typescript-5-8-arrives-in-beta.html

Voir aussi

News copyright owned by their original publishers | Copyright © 2004 - 2025 Zicos / 440Network
Date Actuelle
mar. 4 févr. - 09:34 CET