Some developer has written a method whose structure is given below.
export function ClassMethodTracer(className: IMyClass, methodName: string): void {
const targetClass: IMyClass = className;
const targetMethod: string = methodName;
const propertyName = `Custom/${targetClass.name}/${targetMethod}/tracing`;
const newMethodName = `Custom${targetClass.name}${targetMethod}`;
if (!targetClass.prototype[propertyName]) {
targetClass[newMethodName] = targetClass[targetMethod] as IMethod;
const transactionName = `Custom/${targetClass.name}/${targetMethod}`;
targetClass[targetMethod] = function (...args): LooseObject {
return newrelic.startBackgroundTransaction(
transactionName,
(): LooseObject => (targetClass[newMethodName](...args)) as LooseObject, /* line 12 */
);
};
targetClass.prototype[propertyName] = true;
}
}
I am getting Unsafe call of an `any` typed value linting error in line number 12. How can I solve this linting issue (I don't want to suppress it).
In the above piece of code, we can see there are three more types IMyClass, IMethod and LooseObject whose structures are as follows.
export interface IMyClass {
new (name: string): any;
prototype: {
newMethod: IMethod;
[key:string]: any;
};
}
export interface IMethod {
(...args: any[]): LooseObject;
}
export interface LooseObject {
[key: string]: any;
}
I don't want to suppress linting warnings and errors and I cannot find any way to solve this linting issue.