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

276
Visualizações
La clase 'MonitoringError' extiende incorrectamente la clase base 'Error'

Estoy tratando de extender la clase Error con lo siguiente (para monitorear con Sentry en React Native) pero obtengo el siguiente error.

 Class 'MonitoringError' incorrectly extends base class 'Error'. Types of property 'name' are incompatible. Type 'string | boolean | CaptureContext | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'.

Con el siguiente código

 import { CaptureContext } from '@sentry/types'; import { ComponentType } from 'react'; import { FallbackProps } from 'react-error-boundary'; import { eventMonitoring } from './SentryCrashlyticsService'; export class MonitoringError extends Error { constructor( public message: string, public name?: string | CaptureContext | boolean, public captureContext?: CaptureContext | boolean, ) { super(message); } public capture: () => void = () => { let skipLogging = false as boolean | undefined; let ctx = this.captureContext; let name; if (this.name && typeof this.name === 'string') { name = this.name; } else if (this.name && typeof this.name === 'boolean') { skipLogging = name; } else if (name) { ctx = name as CaptureContext; } if (typeof this.captureContext === 'boolean' && !skipLogging) { skipLogging = true; } if (!skipLogging) { eventMonitoring.captureException(this, ctx as CaptureContext); } }; }

¿Cuál es la mejor manera de extender, si es posible?

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