I want to reference the type of a class constructor itself, not its instance.
class A {
static a = 1;
b = 2;
}
let a: A; // a is an instance of A
a.b === 2 // this works as expected
let aClass: A['constructor'];
aClass.a // not found in Typescript
You can use typeof A to reference the class itself and not an instance of the class, and the class is represented by the constructor
let aClass: typeof A =A
aClass.a //ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With