'use strict'; const factory = (ClassCtor) => (...args) => { function ClassActivator() { const self = Reflect.construct(ClassCtor, args); // @ts-ignore Object.assign(this, self); } ClassActivator.prototype = Object.create(ClassCtor.prototype); return ClassActivator; }; /* const Basecrud = factory( class { constructor(public name: string, public collectionId: string) {} getName = () => this.name; getCollectionId = () => this.collectionId; } ); class TestCrud extends Basecrud("test-crud", "collection-uuid") {} const testCrud = new TestCrud(); console.log(testCrud.getName()); */ exports.factory = factory;