我需要一个关于不覆盖超类原始方法的装饰器的示例
示例:
class Animal {
sayHello(...params){
}
}
@SomeDecorator()
class Dog extends Animal{
}
function SomeDecorator(newValue?){
return (target) => {
// method
const metadataValue = Reflect.getMetadata(
'someKey',
target.prototype.sayHello,
) || [];
Reflect.defineMetadata(
'someKey',
[
...metadataValue,
{
newValue
}
],
target.prototype.sayHello,
);
}
}
我需要装饰器仅修改子类的元数据,而修改超类的方法
感谢您的帮助。