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:
- Medium: https://medium.com/@nhannguyendevjs/
- Dev: https://dev.to/nhannguyendevjs/
- Hashnode: https://nhannguyen.hashnode.dev/
- Linkedin: https://www.linkedin.com/in/nhannguyendevjs/
- X (formerly Twitter): https://twitter.com/nhannguyendevjs/
- Buy Me a Coffee: https://www.buymeacoffee.com/nhannguyendevjs
Top comments (0)