Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
How to counter unsafe call linting issue in this piece of code?

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda