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
{{ message }}
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
Properties on object literals are defined as new value on the object. It does not invoke any newly defined setters. This is different than what Object.assign on a recently defined object does.
letrecord={x: 1};letobj={setx(){thrownewError();}, ...record};// not errorobj.x;// 1
What is the rationale for this? It feels a bit surprising, as it breaks with the mental model of being sugar over Object.assign.
The text was updated successfully, but these errors were encountered:
That would be what I imagine the desugaring to look like, given that record may be an arbitrary parameter whose enumerable properties aren't known in advance.
This difference makes it harder to switch between ES5 and ES20xx syntax, as you'd need to keep this (admittedly rare) special case in mind.
Indeed, TypeScript gets this wrong: microsoft/TypeScript#13668. And it's hinted in that issue (on my phone, can't check yet) that Babel may be wrong as well.
I noticed the following caveat in
Issues.md
:What is the rationale for this? It feels a bit surprising, as it breaks with the mental model of being sugar over
Object.assign
.The text was updated successfully, but these errors were encountered: