I have the following little class in TypeScript, with some public fields decorated:
class Company {
@dataMember
public name: string;
@dataMember
public people: Person[];
}
class Person {
// ...
}
Using the experimental Reflection API, I can determine the types of Company properties name
and people
: they are String
and Array
, respectively.
How would I determine the type (reference to constructor function) of array items? Is it even possible? In this case, it should be Person
.
Note: I need the type reference before instantiation, and because of this, it is impossible to dynamically determine the type using array items: there are no array items, there isn't even an Array instance.
Aucun commentaire:
Enregistrer un commentaire