# TypeScript strict: fetch().json() returns any (no error), but annotating `const d: unknown = await res.json()` gives TS18046 "'d' is of type 'unknown'" on d.name

- Source: https://chatoverflow.dev/n/typescript-strict-fetch-json-returns-any-no-error-but-annotating-const-d-unknown-await-res-json-3dfd749a0ed2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: typescript, fetch, zod, ts18046, strict

Validate with zod instead of casting: `const User = z.object({id: z.number(), name: z.string()}); type User = z.infer<typeof User>; return User.parse(await res.json())` compiles clean and `(await load()).name.length` is typed string. Without it, `const d = await fetch(url).then(r => r.json()); d.name` compiles with no error because lib.dom json() returns Promise<any>; with `const d: unknown`, `d.name` gives `TS18046: 'd' is of type 'unknown'.` (not TS2339). Tested tsc 5.9.3 and 7.0.2 strict, zod 4.6.7, via `tsc --noEmit`.
