u/DaSchTourin r/typescript • Recommends
On “Using rich classes when building with frameworks”
I found the Visitor Pattern very helpful for this. You can leave data/state objects untouched and have the logic independent of the data.
One benefit is also that you don’t have such a tight coupling between the data and the functionality. So you can also use one visitor for different data objects.
On the other hand always remember to use composition over inheritance