2 min

The beta of TypeScript 4.9 is available, including substantial enhancements such as the new ‘satisfies’ operator. However, ECMAScript Decorators, which were scheduled for this release, are likely to be delayed.

TypeScript 4.9 will be available as a release candidate on November 1 and as a final version in mid-November. Daniel Rosenwasser, senior program manager, stated in a blog post that “the new ‘satisfies’ operator allows users to validate that the type of an expression matches some type without adjusting the resulting type of that expression”, adding that “satisfies can be used to catch lots of possible errors”.

What can users expect?

In certain ways, the satisfies operator is unusual. It performs extra type checking without modifying any types, similar to what TypeScript does with JavaScript. On the other hand, the new operator is a creative workaround for the unintended consequences of modifying the types themselves.

This release contains much more. TypeScript 4.9 prohibits direct comparison with NaN (not a number), because nothing in JavaScript is equal to NaN, including NaN itself. Developers should use Number.isNaN, but many users inadvertently end up verifying using someValue == NaN instead, according to Rosenwasser.

ECMAScript Decorators

Another new feature is TypeScript’s watch mode, which offers automatic file compilation as files change. It has also been modified to use file system events by default instead of polling for changes, which is less efficient.

It will still use polling as necessary, but for most developers, Rosenwasser said, this should give a significantly less resource-intensive experience.

However, one item initially planned for TypeScript 4.9 is missing: ECMAScript Decorators. They are a tricky issue because TypeScript already provides experimental decorators, which are annotations that change the behaviour of classes or class members.

“While decorators have reached stage 3, we saw some behaviour in the spec that needed to be discussed”, Rosenwasser explained. “Between addressing that and reviewing the changes, we expect decorators will be implemented in the next version.”

Tip: New Visual Studio extension makes C# code easier to read