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

188
Visualizações
errorObj: unknown Object is of type 'unknown'

I am getting the error while using async, await in useEffect hook.

useEffect(() => {
if (contentLoader) {
      (async () => {
        try {
          const data = await promise;
          setData(data);
        } catch (errorObj) {
          if (!errorObj?.value) { //here i'm getting --> errorObj: unknown Object is of type 'unknown'.
            setError(errorObj);
            console.log(`loading document error: ${errorObj}`);
          }
        }
      })();
    } else // something else
}, [..])

whats wrong in my code.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're using TypeScript 4.4 or newer with [use-unknown-catch-variables] (https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables) enabled.

The easiest fix, if you don't know the actual type of the error thrown, is to just tell TypeScript that it's any, not unknown.

catch (errorObj) {

->

catch (errorObj: any) {
about 4 years ago · Juan Pablo Isaza Relatório
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