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.
if we are applying all instance properties AFTER super: m == {a: null, b: 'foo', c: 123, d: 0} - hard to use in common usecases with inheritance
if we are applying all instance properties BEFORE super: m == {a: null, b: 'bar', c: 123, d: 0} - all as expected.
The text was updated successfully, but these errors were encountered:
Because ES classes generate the instance object/value starting at the base-most constructor, there is no good mechanism by which it would be possible to execute the fields on MyModel before the ModelBase constructor has executed.
Desugaring this example into expando constructor-assignment helps to illustrate the problem:
classModelBase{constructor(initParams){for(letiininitParams){this[i]=initParams[i];}}}classMyModelextendsModelBase{constructor(initParams){/** * `this` is in TDZ here because `this` is only allocated after a call to super() * for derived classes. As such, it is not possible to assign to `this` here * because `this` doesn't exist yet. */super(initParams);// Only at this point has `this` been allocated and boundthis.a=null;this.b='foo';this.c=123;}}
if we are applying all instance properties AFTER super: m == {a: null, b: 'foo', c: 123, d: 0} - hard to use in common usecases with inheritance
if we are applying all instance properties BEFORE super: m == {a: null, b: 'bar', c: 123, d: 0} - all as expected.
The text was updated successfully, but these errors were encountered: