Pseudotronics
setStore TypeScript Issue
I have a object store that has an interface like this:
type1 looks like this:
type2 looks like this:
Now I have a components where I pass in the following props struct
Within the component I make calls like:
(where props.id = "object1" or "object2")
These do not create any typescript error.
When I make a call like this:
(where props.id = "object2")
I get an error like this:
The code runs fine without error, so I feel like I am not actually using setStore incorrectly.
Why doesn't TypeScript recognize "invert" as valid Part in this situation? Is there any way I can fix this without supressing the TypeScript error?
15 replies
How to make a reactive copy of a store.
I have an application where I am modifying the configuration for a device. The configuration is maintained in a store and provided via context to the app.
What I want to do is make a copy of part of the store (the portion that represents the configuration) of the device and use it as the reactive source for a configuration page. The idea here being I want to copy the current configuration and then let the user modify the copy via reactive controls before applying the configuration to the device via a save button.
Here is what I have tried to do:
My intention was to intentionally break the reactivity through prop drilling, however that doesn't seem to work. When I modify the copy it also modifies the original.
Has anyone ever done something similar to what I am trying to do? Any help or ideas would be very much appreciated.
4 replies