TypeScript: class composition
问题 Based on this awesome Composition over Inheritance video by MPJ, I've been trying to formulate composition in TypeScript. I want to compose classes , not objects or factory functions. Here is my effort so far (with a little help from lodash ): class Barker { constructor(private state) {} bark() { console.log(`Woof, I am ${this.state.name}`); } } class Driver { constructor(private state) {} drive() { this.state.position = this.state.position + this.state.speed; } } class Killer { constructor