dimanche 2 juin 2019

Get Class properties and values using Typescript reflection

Say I have a class

Class A {}

And would like to iterate through Class A properties (checking for null values) only knowing that Class A will have properties but might vary in property names and number of properties (e.g.)

Class A {
  A: string;
  B: string;
} 

or

Class A {
  B: string;
  C: string;
  D: string;
}

Is there a way I can iterate through Class A properties and check if the values are null?





Aucun commentaire:

Enregistrer un commentaire