class A {
constructor() {
this.test = Math.random();
}
instance() {
return new this();
}
}
class B extends A {}
const b = new B(); // b.test = 0.3213123213154353
const c = b.instance(); // c.test = 0.43234871231123
return new A();
, но мне нужно полиморфное поведение.return new this.constructor();
This expression is not constructable. Type 'Function' has no construct signatures
const { constructor } = Object.getPrototypeOf(this);
return new constructor();