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
I'm upgrading some projects from immutable 3.8 to immutable 4.0 and have found some confusing behavior when assigning undefined to a Record key. With version 3 it was possibile to set a value to undefined, now it seems it acts as a sort of "reset to default value", which at first is quite confusing.
I see no mention of this behavior on the changelog nor in the documentation, and it's not clear if it's wanted or not. in the first case it should probably be listed as a breaking change imho. (however my opinion is that it should be possible to assign undefined, like in v3)
It seems like it is mentioned in the PR for the Record change #1135
This is also a breaking change as delete() (aka remove()) and clear() are no longer available - previously these methods reverted values to their default value, now that can be done with set(k, undefined).
Though it seems delete() and clear() were added back in later #1157
So the change seems intentional, but just wasn't mentioned as a breaking change. And I do also agree it's a bit unintuitive and would prefer the original behavior. Just because a default value isn't undefined doesn't mean we never want to set it to undefined.
What happened
I'm upgrading some projects from immutable 3.8 to immutable 4.0 and have found some confusing behavior when assigning
undefined
to aRecord
key. With version 3 it was possibile to set a value toundefined
, now it seems it acts as a sort of "reset to default value", which at first is quite confusing.I see no mention of this behavior on the changelog nor in the documentation, and it's not clear if it's wanted or not. in the first case it should probably be listed as a breaking change imho. (however my opinion is that it should be possible to assign undefined, like in v3)
How to reproduce
V4
V3
The text was updated successfully, but these errors were encountered: