jeudi 23 février 2017

How to get child classes which implement a certain base class using reflection in Type Script?

Can we use reflection in Type Script just like C# to get the list of classes which implement a certain base class?

For example, let say Snake and Horse implement the base class Animal. Now I need to get classes which implement Animal. Similar to what we can do in C#:

C# equivalent Code:

var childTypes = assembly.GetTypes().Where(_ => _.IsSubclassOf(typeof(Animal)));

Type Script classes:

class Animal {
}

class Snake extends Animal {
}

class Horse extends Animal {
}





Aucun commentaire:

Enregistrer un commentaire