How to make setStore treat a class/interface as an opaque value instead of a partiable one?
So, I'm currently using a UOM library called @buge/ts-units. It has this interface called Quantity that I want to use in my stores. For example:
The problem is that whenever I want to use
setStore
with the path syntax, this is allowed:
It seems to be because in Typescript, the type used for the last argument is Partial<Length>, which allows a number(???) to be accepted. Ignoring that, I would want to treat Length
as a opaque, unpatchable, immutable value just like any other primitive type (boolean, number, bigint, et cetera). The work around I found is essentially avoiding the path syntax and merge at the top-level:
1 Reply
Okay, I decided to try patching it myself and pulled from
SolidStore.Unwrappables
. It's supposed to include anything that shouldn't be wrapped reactively. Though, it doesn't imply the object in question shouldn't be patchable, it works okay-enough for my purposes. I changed the type of StoreSetter
, which determines how some value should be modified, to be this instead:
So, now the partialization is behind a condition.
And it solves my problem, I guess? Is there a better way?