Answer the question
In order to leave comments, you need to log in
How to correctly write the type of the argument so that the static properties of the class are visible?
There is the following code:
class A {
static b = 123;
}
function f(cls: new() => A) {
console.log(cls.b); // Ошибка: Свойство "b" не существует в типе "new () => A".
}
cls
I want to get a class A
in, along with static properties?
Answer the question
In order to leave comments, you need to log in
So?
class A {
public static b: number = 123;
}
function f<T extends {b: number, new (...args: any[]): InstanceType<T>}>(cls: T) {
console.log(cls.b);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question