mercredi 27 février 2019

How to iterate over non existent member of a class?

How do I achieve the following prototype-code:

class test {
    a: number;
    b: boolean;
    c: string;
}

for (const so in test)
    so, //'a', 'b', 'c'...
    //so.type //'number', 'boolean', 'string'...

I don't have any idea how to get the type however I tried creating a new object and iterating over it for the names but obviously this didn't work since the class members were left uninitialized.





Aucun commentaire:

Enregistrer un commentaire