类似于 Object.keys 方法会返回附加在对象上的所有键名称列表,是否有一种方法可以返回附加到类上的所有静态变量名称和所有静态方法名称?
Typescript 示例:
class FindStatics {
static num1:string = 'Num 1';
static num2:string = 'Num 2';
notStatic:string = "I'm not static";
static concat ():string {
return `${FindStatics.num1} loves ${FindStatics.num2}`
}
addToNonStatic(str:string):string {
return `${this.notStatic} + ${str}`;
}
}
我想要做的是只获取静态变量和方法名,所以在上面的例子中,我希望返回num1
、num2
和concat
。