DEV Community

Nhan Nguyen
Nhan Nguyen

Posted on

Using satisfies Operator in TypeScript

Image description

The satisfies operator was Introduced in TypeScript 4.9, which allows you to opt for a different kind of type inference from the default type system.

It combines the best of both type annotations and default type inference.

It ensures that a value adheres to a specific shape.

The main difference between as and satisfies is that as is used for explicit type assertions when you want the type of value to become the same as a particular type. But satisfies does not force them to be similar. Instead, it makes a new type that meets.

I hope you found it useful. Thanks for reading. šŸ™

Let's get connected! You can find me on:

Top comments (0)