When B extends A, is it possible for A to define a method that generates a new instance of B?
class SetA {
constructor(public items:any[]) {
}
createNew(items){
return new *typeof this*(items); //<-- insert actual implementation here
}
clone(){
return this.createNew(this.items);
}
}
class SetB extends SetA { }
var x = new SetB([1,2,3]);
x.clone(); //<-- creates a new SetB object