mardi 31 décembre 2019

Typescript: How to get all property decorators from only the class type?

const metadataKey = "metadataKey";
class User
{
    @Reflect.metadata(metadataKey, 1)
    name: string;
    @Reflect.metadata(metadataKey, 2)
    age: number;
}

getPropertyDecorators(User); // I hope it can return [1, 2]

I hope the function getPropertyDecorators doesn't need to create an instance of User.





Aucun commentaire:

Enregistrer un commentaire