1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
class Spread {
suspendPaint = () => { }
resumePaint = () => { }
}
function spreadPerformance() {
return function (target: A, propertyName: string, propertyDescriptor: PropertyDescriptor) {
const method = propertyDescriptor.value;
console.log('target', target)
console.log('propertyName', propertyName)
console.log('propertyDescriptor', propertyDescriptor)
propertyDescriptor.value = function (...args: any[]) {
console.log(1, this.name)
method.call(this, ...args)
console.log(2, this.name)
};
return propertyDescriptor;
};
}
class A {
constructor(public name: string) {
A.age = 22
}
public static age = 18
@spreadPerformance()
fillDataToSpanCell(spread: Spread) {
console.log(`run ${this.name}`, spread)
}
}
const a = new A("hello")
a.fillDataToSpanCell(new Spread())
|