Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda