function logIfParamsSumGT100(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
const originalMethod = descriptor.value;
descriptor.value = function(...args: number[]) {
const sum = args.reduce((acc, val) => acc + val, 0);
if (sum > 100) {
console.log(`Method ${propertyKey} called with args: ${args}`);
}
return originalMethod.apply(this, args);
};
return descriptor;
}
class MyClass {
@logIfParamsSumGT100
method1(a: number, b: number) {
return a + b;
}
@logIfParamsSumGT100
method2(c: number, d: number, e: number) {
return c + d + e;
}
}
const myClass = new MyClass();
myClass.method1(50, 60);
myClass.method2(30, 40, 20);