How can I get reference to the constructor function for any object in typescript?
Example in JavaScript:
var anyObject = new this.constructor(options);
or
var anyObject = new someObj.constructor(options);
or
class Greeter {
greeting: string;
constructor(message: string, options: any) {
this.options = options;
this.greeting = message;
} greet() {
return "Hello, " + this.greeting;
} createAnyObj(){
return new this.constructor(this.options);
}
}
var t= new Greeter('mes',{param1: 'val1'});
var b=t.createAnyObj();
Thanks.
More examples:
createAnyObjmethod? what does it expected to return?