انتقل إلى المحتوى
#0825
Exec

The type is still there when the request arrives

Your customers integrate against /api/orders/[id]. The handler returns whatever the last refactor made it return. TypeScript checked the shape on your laptop, the transpiler threw the types away, and the wire got whatever came out.

On exec, the type goes in a comment above the handler: // @return-type { id: string, total: number, status: 'paid' | 'open' }. With // @return-type-mode strict, a response that doesn't match is rejected before it leaves the box: the customer gets an error, not a silently reshaped object. warn logs the mismatch and lets it through; dev enforces outside production and relaxes in it. The mode is one word, set per endpoint.

The compiler forgets the type at build time. Exec has no build, so the type is still there when the request arrives.

Exec has no build, so the type is still there when the request arrives.