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

**Code:** `TS2571: Object is of type 'unknown'` · **Category:** TypeScript · **Seen on:** TypeScript

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/typescript/ts2571-object-is-of-type-unknown)
