首页 > 解决方案 > 按类型获取类 PropertyInfo

问题描述

考虑到我有休闲班

export class myClass{
  test?:number;
  test2?:string;
  test3:boolean;
  constructor(){
   this.test3=true;
}
}

我想获取类中包含的属性及其类型的列表

我想要.GetProperties<myClass>()回来的东西[{name:"test", "type":"number"},etc]

打字稿可以吗?

标签: javascripttypescript

解决方案


推荐阅读