// 混入对象1class Bird { canFly: boolean; fly() { this.canFly = true; console.log('I can fly') }}// 混入对象2class Fish { canSwim: boolean; swim() { this.canSwim = true; console.log('I can swim') } }// 新对象class FlyFish implements Bird, Fish { constructor() {} canFly:boolean= false; canSwim:boolean= false; fly: () => void; swim: () => void;}function doMixins(derivedCtor: any, baseCtors: any[]) { baseCtors.forEach(baseCtor => { Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => { derivedCtor.prototype[name] = baseCtor.prototype[name]; }); });} doMixins(FlyFish, [Bird, Fish]);let flyFish = new FlyFish();console.log(flyFish.canFly);flyFish.swim();