TypeScript
class Foo {
private log = 'foo';
public plog = 'plog foo!';
@l('True story, bro!')
run(name) {
console.log('run ' + name);
}
}
function l(what) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
const original = descriptor.value;
descriptor.value = function (...args) {
console.log(`${what} ${this.log}`);
return original.apply(this, args);
}
return descriptor;
};
}
const x = new Foo();
x.run('Nick');