A type generated from a schema, and the assertion I removed

Types generated from an OpenAPI document, and a response validated at runtime rather than asserted at compile time.

import type { paths } from './api'

type Order = paths['/v2/orders/{id}']['get']
  ['responses'][200]['content']['application/json']

// what I had
const order = await res.json() as Order   // a claim

// what it is
const order = OrderSchema.parse(await res.json())
// a runtime check, whose output type is inferred

A generated type describes the specification and the specification is a document, not a guarantee — the assertion was true until the day an optional field arrived as null. Parsing at the boundary costs a few kilobytes and applies only to the three responses that come from outside our control, which is where the schema and reality can diverge.