google / google/ground-platform
[Code health] Create mixin to allow immutable data objects to be copied with changes
Open
type: code health
web
- Dominant language
- TypeScript
- Stars
- 249
- Forks
- 112
- Avg merge
- 10h 7m
- Merged PRs (30d)
- 4
Description
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 });
}
```
Contributor guide
Assessment
This issue has not been assessed yet.