Working on a typescript project, I encountered over 2000 events(methods) that are triggered during user operations. To ensure performance metrics for all events related to the completion of an operation, I decided to make 'executionTime' a mandatory parameter with a method decorator. Here's a snippet of my code:
class AllEvents {
@performanceDecorator(true)
public static firstEvent(param1: string, param2: string, executionTime: number): void {
//some tasks...
}
@performanceDecorator(true)
public static secondEvent(param1: string, param2: string): void {
//some tasks...
}
@performanceDecorator(true)
public static thirdEvent(param1: string, param2: string, executionTime: number): void {
//some tasks...
}
}
function performanceDecorator(value: boolean) {
//..................
}
Being new to typescript, I'm struggling to determine how to implement the logic inside the performanceDecorator function. My goal is to throw errors if a method does not include the 'executionTime' parameter.