TypeScript · Boundaries
TS0005Validate deserialized values before typing them
Reject direct type claims on values returned by JSON parsing, Fetch API bodies, and browser storage.
vite-doctor/typescriptboundarieswarnNo fix
Why it happens
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.
Fix
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))
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --rules typescript/boundaries/no-unvalidated-deserialization