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

TypeScript 5.7 arrives with improved error reporting

Friday November 22, 2024. 08:57 PM , from InfoWorld
TypeScript 5.7, the latest planned release of Microsoft’s JavaScript variant with syntax for types, is now available in a production release. With version 5.7, the language’s type system is now able to report errors when variables have never been initialized.

General availability was announced November 22, following a November 8 release candidate and an October 9 beta. The production release can be installed through NPM using the command npm install -D typescript.

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-arrives-with-improved-error-reporting.html

Related News

News copyright owned by their original publishers | Copyright © 2004 - 2024 Zicos / 440Network
Current Date
Dec, Tue 24 - 04:45 CET