I get following error:
TS2351 Cannot use 'new' with an expression whose type lacks a call or construct signature.
class A {
constructor() { ... }
refresh() { return new this.constructor; }
}
new this.constructor works in pure JS.
Thanks:)
The type of constructor
is just Function
, unfortunately. You can write this instead:
class A { constructor() { } refresh() { return new (<typeof A>this.constructor); } }
Most helpful comment
The type of
constructor
is justFunction
, unfortunately. You can write this instead: