/** * Apply the given mixin classes to the given constructor. * @param derivedCtor * @param {array} baseCtors */ export function applyMixins(derivedCtor: FunctionConstructor, baseCtors: any[]): void { baseCtors.forEach(baseCtor => { Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => { const desc = Object.getOwnPropertyDescriptor(baseCtor.prototype, name) if ( typeof desc !== 'undefined' ) { Object.defineProperty(derivedCtor.prototype, name, desc) } }) }) } /** * Base type for a constructor function. */ export type Constructor = new (...args: any[]) => T