#Should I declare all my variables with satisfies ?

3 messages · Page 1 of 1 (latest)

stray comet
#

Hi,

Should I declare all my variable with satifies instead of typing like so :

let myVariable: MyType = { ... };
let myVariable = { ... } satisfies MyType;

Is satisfies more "strict" than a classic typying definition & what are the props/cons of both example ? Thank you 🙂

vague laurel
#

I think satisfies has its own usage when you would like to keep types that derive from union types. Other than that, I think most variables have no need to be that specific and should be "generic" enough.

Satisfies is more verbose and being after the value itself makes it harder to track.

I am open to arguments with examples.

stray comet