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

TypeScript 5.7 improves error reporting

Thursday October 10, 2024. 10:25 PM , from InfoWorld
TypeScript 5.7, the latest planned release of Microsoft’s JavaScript variant with syntax for types, is now available as a beta release. With the update, the language’s type system is now able to report errors when variables have never been initialized.

Introduced October 9, the TypeScript 5.7 beta can be accessed through NPM using the command npm install -D typescript@beta.

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 is accessed in a separate function, the type system does not know when the function will be called, and instead takes an optimistic view that the variable will be initialized. While TypeScript 5.7 still is lenient on variables that have possibly been initialized, the type system now is able to report errors when variables have never been 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 then compiled into JavaScript code when ready.

Following the beta, a release candidate for TypeScript 5.7 is planned for mid-November, soon to be followed by a stable release. TypeScript 5.7 comes on the heels of the September release of TypeScript 5.6, which features capabilities that include 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

Related News

News copyright owned by their original publishers | Copyright © 2004 - 2024 Zicos / 440Network
Current Date
Oct, Wed 16 - 14:20 CEST