7

TypeScript v4.9 Beta: Introducing the new satisfies operator

 1 year ago
source link: https://devm.io/typescript/typescript-4-9-beta
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Satisfaction and improvements in the newest update

TypeScript v4.9 Beta: Introducing the New Satisfies Operator

Sarah Schlothauer

26. Sep 2022


Microsoft announced the beta release of TypeScript version 4.9 on September 23, 2022. While the final version is slated for a mid-November, 2022 release, the beta release gives developers a chance to check out several big new improvements and features, including the satisfies operator.

Developed by Microsoft, TypeScript is an open source programming language that adds new syntax to JavaScript. Since it builds on top of JavaScript as a syntactical superset, it can run anywhere that JS can.

The newest beta version adds a host of new upgrades, most notably it adds the new satisfies operator and improvements for the in operator.

New in v4.9 beta

TypeScript 4.9 beta adds the new satisfies operator, which will help developers catch issues in their code early.

From Daniel Rosenwasser’s announcement blog:

The new satisfies operator lets us validate that the type of an expression matches some type, without changing the resulting type of that expression. As an example, we could use satisfies to validate that all the properties of palette are compatible with string | number[]:

The in operator also receives a new improvement.

Rosenwasser writes:

TypeScript 4.9 makes the in operator a little bit more powerful when narrowing types that don’t list the property at all. Instead of leaving them as-is, the language will intersect their types with Record<"property-key-being-checked", unknown>.

TypeScript v4.9 beta also adds/changes:

  • File system events will now be used in file watching
  • Equality checks on NaN (Not a Number)
  • Improvements to Promise.resolve

As with any update (especially a beta release), be aware of potentially breaking changes and bugs. This is not the final state for TypeScript v4.9, so proceed with this in mind when using it in your projects.

Upgrade and test it out

If you are interested in testing out the beta version, you can install v4.9 via NuGet, an npm command, or by downloading Visual Studio Code 2022/2019.

However, if you would prefer to use the final release, you will only have to wait until mid-November. According to the TypeScript iteration plan, the final release for TypeScript 4.9 is scheduled for November 15th, 2022. Before the final version, there will be one more release candidate and some bug fixes.

Naturally, this release iteration is if all goes according to plan and is subject to change. There is always a possibility of delays or rescheduling if there are any show stopping issues.

TypeScript has been continuously increasing in usage, according to statistics from the annual Stack Overflow Developer Survey. If you’re new to the language, view the documentation and follow the newcomer guides. Or, test it out in the playground and see how it works directly in your browser.

Join the community on GitHub, Discord, and stay up to date with new releases and news.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK