You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a good point, but simply making the properties writable will probably not be good enough (since the changes would not be detectable by react components etc.). I think a real solution would need something like a Feature class with properties backed by the reactivity API, as an "evolution" of the BaseFeature interface.
For the time being, I can recommend two approaches:
Instead of changing the existing feature instance, create a new one as a copy, with the updated properties. For example:
This will work well with react components that detect changes based on value "sameness" (mutating existing values would be a bad idea).
If it works in your use case, simply cast away the "readonlyness". It is just a TypeScript annotation and could be ignored. For example:
typeWritableFeature=BaseFeature&{properties: Record<string,unknown>};constexistingFeature= ...;constwritableFeature=featureasWritableFeature;// use at your own riskwritableFeature.properties.foo=3;
Issue description
BaseFeature as a representation of a feature should have the ability to change the properties.
properties?: Readonly<Record<string, unknown>> => properties?: Record<string, unknown>
Validations
The text was updated successfully, but these errors were encountered: