We take a look at the satisfies Typescript operator and how to use it, when to use it and why you should use it instead of Type annotations and typer assertions.
I guess you are missing the point, satisfies key word adds type checking to your declarations without having the same side effect as Type Annotation or Assertion where the variable becomes that type (which you might need to narrow later on), leaving it in the narrow type which it was defined as. Yes, the examples would still work without it, but nothing prevents you from making a mistake without satisfies (or alternatives which might have undesirable characteristics as discussed in the useless article), It's up to you whether you want to use the satisfies operator or not, but it's important to understand how exactly to use it.
Omitted word:
> Typescript will make you jump through *??hoops??* to accept the variable,
Thanks, you mean like jump through multiple hoops, as the proper sentence?
Great writeup!
Thank you
Completely useless and stupid article. You could literally skip the satisfies keyword altogether in these examples and it would work exactly the same.
I guess you are missing the point, satisfies key word adds type checking to your declarations without having the same side effect as Type Annotation or Assertion where the variable becomes that type (which you might need to narrow later on), leaving it in the narrow type which it was defined as. Yes, the examples would still work without it, but nothing prevents you from making a mistake without satisfies (or alternatives which might have undesirable characteristics as discussed in the useless article), It's up to you whether you want to use the satisfies operator or not, but it's important to understand how exactly to use it.