Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!