Real world example I ran into
With this foundational knowledge thanks to the great Steve Sewell, one scenario which I ran into issues that were solved by satisfies
is as follows:
With defaultState: State
and data not having any values, typescript cannot infer. So we need to instead use satisfies.
The as
keyword, would not work here to fix the issue either since in this context as
doesn’t tell typescript which data is being used DataA
or DataB
so it can’t tell us if its right or wrong.