Reputation: 9914
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
Upvotes: 4
Views: 874
Reputation: 250366
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
Upvotes: 5