TS2571: Object is of type 'unknown' TypeScript Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

TypeScript: error TS2571: Object is of type 'unknown'.

You used a value typed unknown (often catch (e) or JSON.parse result) without narrowing.

Exact message you may see error TS2571: Object is of type 'unknown'.Object is of type 'unknown'. ts(2571)TS2571 Object is of type 'unknown'error TS2571
Seen on: TypeScript

Meaning

unknown forces checks before use: if (e instanceof Error) e.message, typeof x === "string", type guards, or validate with zod. In catch clauses with useUnknownInCatchVariables (strict) e is unknown. Avoid casting to any blindly.

Common causes

  • catch (e) accessing e.message
  • JSON.parse / response.json() result unknown
  • Generic unknown params
  • Third-party callbacks typed unknown
  • strict mode enabled recently

⚡ Quick fix

  1. if (e instanceof Error) { console.error(e.message); }
  2. Use type guards/zod to validate
  3. const data = (await res.json()) as MyType only after validation

Detailed fix by platform

TypeScript

  1. try { run(); } catch (e) { const msg = e instanceof Error ? e.message : String(e); }

How to diagnose

  1. Value — unknown?
  2. Guard — typeof/instanceof?
  3. Validation — zod?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Cannot find module './App.vue' or its corresponding type declarations — TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations. (Vue)Cannot find module '.…TS1005: ';' expected / ',' expected (syntax error) — TypeScript: error TS1005: ';' expected. (TypeScript)TS1005: ';' expected …TS1128: Declaration or statement expected — TypeScript: error TS1128: Declaration or statement expected. (TypeScript)TS1128: Declaration o…TS1192: Module has no default export — TypeScript: error TS1192: Module '"./utils"' has no default export. (TypeScript)TS1192: Module has no…TS1208: File cannot be compiled under '--isolatedModules' because it is considered a global script file — TypeScript: error TS1208: 'index.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement (TypeScript)TS1208: File cannot b…TS18046: 'x' is of type 'unknown' — TypeScript: error TS18046: 'e' is of type 'unknown'. (catch variable) (TypeScript)TS18046: 'x' is of ty…TS2339 — TS2339: Property 'x' does not exist on type 'Y'. (Node.js)TS2339TS2352: Conversion of type may be a mistake — TypeScript: error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other (TypeScript)TS2352: Conversion of…TS2571: O…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.