1
オブジェクトに関連付けられたすべてのキー名のリストを返すObject.keysメソッドと同様に、クラスに関連付けられたすべての静的変数名とすべての静的メソッド名を返す方法はありますか?TypescriptまたはES6でクラスのすべての静的変数およびメソッドを表示する方法はありますか?
活字体例:私がやりたい何
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
が返されます。
これらは、「変数」ではありません。それらは「特性」である。 –