TypeScript · TS0005

Validate deserialized values before typing them

Reject direct type claims on values returned by JSON parsing, Fetch API bodies, and browser storage.
TS0005vite-doctor/typescriptboundarieswarnNo fix

Run this rule

pnpm vite-doctor . --rules typescript/boundaries/no-unvalidated-deserialization

Why it matters

JSON, Fetch API bodies, and browser storage contain runtime data. A TypeScript annotation or assertion does not validate that data, so malformed values can enter the program under a trusted domain type.

Deserialize to unknown, or to a JSON type that claims nothing about the contents (unknown, Record<string, unknown>, a JSON value union), and validate with the domain parser before using the value. Keep browser storage reads as string | null.

Example

Validate JSON at the boundary

Before

const user = JSON.parse(text) as User

After

const user = UserSchema.parse(JSON.parse(text))
Copyright © 2026