Is there a way to get properties names of class in TypeScript: in the example I would like to 'describe' the class A or any class and get an array of its properties (maybe only public one ? ), is it possible? or should I instantiate the object first?
class A {
private a1;
private a2;
/** Getters and Setters */
}
class Describer<E> {
toBeDescribed:E ;
describe(): Array<string> {
/**
* Do something with 'toBeDescribed'
*/
return ['a1', 'a2']; //<- Example
}
}
let describer = new Describer<A>();
let x= describer.describe();
/** x should be ['a1', 'a2'] */
Aucun commentaire:
Enregistrer un commentaire