TypeScript 4.9 intros operator for finding coding mistakes

error neon mistake

Microsoft’s TypeScript 4.9, a planned upgrade to the popular, strongly typed language that builds on JavaScript, is now available as a production release. The update features a satisfies operator that can catch errors.

With satisfies, developers can validate that the type of an expression matches some type, without changing the resulting type of the expression. This operator can be used to catch possible errors, such as ensuring that an object has all the keys of some type, but no more than that.

Also in TypeScript 4.9, the in operator has been made more powerful when narrowing types that do not list the property. Instead of leaving them as is, the language will intersect their types with Record<”property-key-being-checked”, unknown>.

TypeScript 4.9 also tightens up checks around how in is used, to ensure that valid property keys are being used.

Introduced November 15, following beta and release candidate stages, TypeScript 4.9 can be downloaded through NuGet or via NPM using the following command:

npm install -D typescript

Other new capabilities and improvements in TypeScript 4.9:

TypeScript 5.0 is due as a beta release on January 24, 2023, with a release candidate set for February 28 and a production release slated to arrive March 14. TypeScript 4.8 shipped on August 25, bringing correctness and consistency improvements as well as file watching fixes.

TypeScript has been on an upswing. CircleCI’s 2022 State of Software Delivery report found that TypeScript had surpassed JavaScript as the most popular devops language. CircleCI cited developer-friendliness as a reason for the surge.

Predecessor TypeScript 4.8 shipped on August 25, bringing correctness and consistency improvements as well as file watching fixes.

Copyright © 2022 IDG Communications, Inc.

Source by www.infoworld.com

Exit mobile version