vendredi 23 mars 2018

Get names of type properties in Typescript [duplicate]

This question already has an answer here:

Give a type, a class for example

class User {
    Name: String;
    Surname: String;
    BirthDate: Date;

    constructor(
        name: String,
        surname: String,
        birthDate: Date) {
        this.Name = name;
        this.Surname = surname;
        this.BirthDate = birthDate;   
        }
}

how can I enumerate the properties names?

The target result would an with the properties names (in any order):

['Name', 'Surname', 'BirthDate']





Aucun commentaire:

Enregistrer un commentaire