I am trying to decorate a class with a decorator (a-la-angular style), and add methods and properties to it.
this is my example decorated class:
@decorator
class Person{
}
and this is the decorator:
const decorator = (target)=>{
return class New_Class extends target {
myProp:string
}
}
but myProp
is not a known property of Person:
person.myProp //Error - myProp does not exist on type Person
How can I decorate a typescript class and preserve type completion, type safety, etc ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…