New TypeScript operator finds coding mistakes

New TypeScript operator finds coding mistakes

TypeScript 4.9’s ‘satisfies’ operator validates that the type of an expression matches some type, catching many possible errors.

Credit: Dreamstime

Microsoft’s TypeScript 4.9, a planned upgrade to the popular, strongly typed language that builds on JavaScript, is now in beta, featuring 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>.

Introduced on September 23, the TypeScript 4.9 beta can be downloaded through NuGet or via NPM using the following command:

npm install -D typescript@beta

Other new capabilities and improvements in the TypeScript 4.9 beta include an update that file watching is powered by file system events by default, only falling back to polling if developers fail to set up event-based watchers. This should provide a less resource-intensive experience when running –-watch mode or running with a TypeScript-powered editor like Visual Studio Code or Visual Studio.

Also, Promise.resolve now uses the Awaited type to unwrap Promise-like types passed to it. This means that it more often returns the right Promise type, but that improved type can break existing code if it was expecting any or unknown instead of a Promise.

Furthermore, TypeScript now errors on direct comparisons against the NaN value and will suggest some variation of Number.isNAN instead.

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.

A production release of TypeScript 4.9 is due in November, preceded by a release candidate. TypeScript 4.8 shipped on August 25, with correctness and consistency improvements as well as file watching fixes.

Follow Us

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags TypeScript



Join key decision-makers within Environmental, Social, and Governance (ESG) that have the power to affect real change and drive sustainable practices. SustainTech will bridge the gap between ambition and tangible action, promoting strategies that attendees can use in their day-to-day operations within their business.

EDGE 2023

EDGE is the leading technology conference for business leaders in Australia and New Zealand, built on the foundations of collaboration, education and advancement.


ARN has celebrated gender diversity and recognised female excellence across the Australian tech channel since first launching WIICTA in 2012, acknowledging the achievements of a talented group of female front runners who have become influential figures across the local industry.

ARN Innovation Awards 2023

Innovation Awards is the market-leading awards program for celebrating ecosystem innovation and excellence across the technology sector in Australia.

Brand Post

Show Comments