공통 기능을 별도 객체에 모아두고, 여러 클래스에 합성할 수 있는 mixin 헬퍼를 만드세요.
export function applyMixins<T>(
target: { prototype: T },
...mixins: object[]
): void;
target.prototype에 복사class Robot {}
const Walker = { walk() { return 'walking'; } };
const Talker = { talk() { return 'hi'; } };
import { applyMixins } from './solution';
applyMixins(Robot, Walker, Talker);
const r = new Robot() as Robot & { walk(): string; talk(): string };
r.walk(); // 'walking'
r.talk(); // 'hi'
Object.getOwnPropertyNames + Object.defineProperty로 prototype에 직접 부착