google / google/ground-platform

[Code health] Create mixin to allow immutable data objects to be copied with changes

Open
#1,038 1 comment 0 reactions 1 assignee Claimed by @rfontanarosa View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.