Is it ok to store newer Javascript objects like Set or Map in the state? Can this cause weird effects with mutability?
export interface StateModel {
aSet: Set<number>;
}
No, it is not OK, and yes it can, depending on how you use it.
Excerpt from the official docs:
Avoid Saving Class Based Instances in Your State
The objects stored in your state should be immutable and should support serialization and deserialization. It is therefore recommended to store pure object literals in your state. Class based instances are not trivial to serialize and deserialize, and also are generally focused on encapsulating internals and mutating internal state through exposed operations. This does not match the requirement for the data stored in state.
This also applies to the usage of data collections such as Set, Map, WeakMap, WeakSet, etc. Since they are not amenable to deserialization and cannot easily be presented for normalization.