Published on Nov 17, 2022
A new operator, ‘satisfies’, validates that the type of an expression matches a type, thereby catching a number of potential errors.
Microsoft has released TypeScript 4.9, a planned upgrade to the popular, strongly typed language based on JavaScript. There is an error-catching operator in the update that satisfies.
With satisfies, developers can validate that the type of an expression matches a given type without changing the resultant type of the expression. As an example, this operator can be used to ensure that an object has all the keys of a particular type, but not more than that.
In TypeScript 4.9, the in operator has been made more powerful when narrowing types that do not list the property. In place of leaving them as is, the language will intersect their types with Record<”property-key-being-checked”, unknown>.
Furthermore, TypeScript 4.9 tightens up checks around how it is used to ensure that valid property keys are being used.
TypeScript 4.9 also includes the following new capabilities and improvements:
By default, file watching is powered by file system events; if developers fail to set up event-based watchers, the system falls back to polling. Using –-watch mode or a TypeScript-powered editor such as Visual Studio Code or Visual Studio should result in a less resource-intensive experience.
The Promise.resolve method now uses the Awaited type to unwrap Promise-like types passed to it. As a result, it returns the correct Promise type more often, but it can also break existing code if it was expecting any or unknown in place of a Promise.
Using Number.isNAN instead of Number.isNAN will result in TypeScript errors on direct comparisons against NaN values.
There is now support for a new ECMAScript feature called auto-accessors, which are declared just like properties in classes, except that they are declared using the keyword accessor instead of the property keyword.
In order to improve performance, the forEachChild function has been rewritten to use a function table lookup instead of a switch statement across syntax nodes. In addition, TypeScript has optimized the way it preserves information about a type in the true branch of a conditional type.
SubstitutionType objects no longer contain the substitute property, which represents the effective substitution, in order to optimize substitution types. Instead, they contain only the constraint property.
TypeScript 5.0 will be released as a beta on January 24, 2023, with a release candidate scheduled for February 28 and a production release scheduled for March 14. A new version of TypeScript 4.8 was released on August 25, bringing improvements to correctness and consistency as well as fixes related to file watching.
The popularity of TypeScript has been on the rise. According to CircleCI’s State of Software Delivery report for 2022, TypeScript has surpassed JavaScript as the most popular devops language. The surge was attributed to developer-friendliness, according to CircleCI.
On August 25, TypeScript 4.8 was released, bringing improvements in correctness, consistency, and the ability to watch files.
Presentations
Browse LSET presentations to understand interesting…
Explore Now
eBooks
Get complete guides to empower yourself academically…
Explore Now
Infographics
Learn about information technology and business…
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
Error: Contact form not found.
[wpforms id=”9030″]