Как изменить значение foo
в моем TestClass
, используя декоратор DefaultValue
?
class TestClass {
@DefaultValue('bar')
private foo;
}
export const DefaultValue = (val: any): PropertyDecorator => {
return (target: any, propertyKey: string | symbol) => {
// Change the value of the decorated property
this[propertyKey] = val; // DOESN'T WORK!
};
}
Не будет работать: this[propertyKey] = val;