如何使用反射元数据从父对象获取所有属性的元数据

问题描述

假设我有一个这样的课程:

class UserDTO {
  @Decorator()
  username!: string;

  @Decorator()
  password!: string;
}

和我的@Decorator在UserDTO.prototype上设置元数据,我可以从以下位置检索元数据:

Reflect.getMetadata('design:type',User.prototype,'username')

是否有从User.prototype本身获取所有这些元数据的方法

我想要这样的东西:

const arr: any[] = Reflect.getAllMetadatas(User.prototype);
// ['username','password']

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)