动态更改打字稿中的属性名称

时间:2018-07-31 11:41:14

标签: typescript class properties typing

我想输入一个类型(无需实现),它可以帮助我在类中添加一些动态字符串

例如:

class Dog() { 
  bark: () => void
  eat: () => void
}
// But actually in runtime, bark is nobark; eat is noeat
// That's why I would like to have such type
inteface Husky extends addSomethingInClass(Dog, 'no') {} 
// Husky.nobark && Husky.noeat can be autocompleted
inteface Corgi extends addSomethingInClass(Dog, 'go') {} 
// Corgi.gobark && Corgi.goeat can be autocompleted 

我想知道是否可以

感谢帮助

0 个答案:

没有答案