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

TypeScript 5.7 improves error reporting

jeudi 10 octobre 2024, 22:25 , par InfoWorld
TypeScript 5.7, the latest planned release of Microsoft’s JavaScript variant with syntax for types, has moved to the release candidate stage. With version 5.7, the language’s type system is now able to report errors when variables have never been initialized.

The release candidate was introduced November  8 following an October 9 beta. It can be accessed through NPM using the command: npm install -D typescript@rc.

With checks for never-initialized variables, the TypeScript team has addressed a situation where TypeScript’s checks for non-initialized variables did not always work. For example, if the not-yet-initialized variable was accessed in a separate function, the type system did not know when the function would be called; it would instead take an optimistic view that the variable would be initialized. While TypeScript 5.7 remains lenient on variables that may have been initialized, the type system now can report errors when variables were never initialized at all.

Also in TypeScript 5.7 is a new compiler option, --rewriteRelativeImportExtensions. When an import path is relative and ends with a TypeScript extension (.ts,.tsx,.mts,.cts), and it is a non-declaration file, the compiler will rewrite the path to the corresponding JavaScript extension (.js,.jsx,.mjs,.cjs). This allows for writing TypeScript code that can be run in place and be compiled into JavaScript code when ready.

TypeScript 5.7 comes on the heels of the September release of TypeScript 5.6, with capabilities including disallowing nullish and truthy checks on syntax that never varies on nullishness or truthiness.

 Other features in TypeScript 5.7 include the following:

TypeScript 5.7 supports --target es2024, which allows developers to target ECMAScript 2024 runtimes.

TypeScript 5.7 supports V8 compile caching in Node.js.

TypeScript now has a more consistent behavior for methods in classes when these are declared with non-literal computed property names.

When a function expression is contextually typed by a signature returning a generic type, TypeScript now appropriately provides an implicit any error under noImplicitAny but outside of strictNullChecks.

When a TypeScript file is loaded in an editor using TSServer (like Visual Studio or Visual Studio Code), the editor will try to find the relevant tsconfig.json file that “owns” the file.

When importing from a.json file under --module nodenext, TypeScript will now enforce certain rules to prevent runtime errors.
https://www.infoworld.com/article/3557641/typescript-5-7-improves-error-reporting.html

Voir aussi

News copyright owned by their original publishers | Copyright © 2004 - 2024 Zicos / 440Network
Date Actuelle
sam. 16 nov. - 01:28 CET