Hack to get the instance type of the given constructable.
Derived from discussion
Declaring https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function|this
This can be used like:
class Parent { public static newInstance<T extends StaticToThis>(this: T): T['prototype'] { return new this }}class Child extends Parent {}const child = Child.newInstance(); // Will be the instance type of Child Copy
class Parent { public static newInstance<T extends StaticToThis>(this: T): T['prototype'] { return new this }}class Child extends Parent {}const child = Child.newInstance(); // Will be the instance type of Child
Rest
Generated using TypeDoc
Hack to get the instance type of the given constructable.
Derived from discussion
Declaring https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function|this
This can be used like:
Example