Open gino-m opened 1 year ago
Based on https://mauricereigman.medium.com/immutable-typescript-classes-with-object-copywith-typesafe-a84fff3971dc:
copyWith(newValues: { [P in keyof this]?: this[P] }): this { return Object.assign(Object.create(this.constructor.prototype), { ...this, ...newValues }); }
We currently use inheritance. We could instead do something like this https://medium.com/@saif.adnan/typescript-mixin-ee962be3224d
Based on https://mauricereigman.medium.com/immutable-typescript-classes-with-object-copywith-typesafe-a84fff3971dc: