Skip to main content

Quick ref: boundary types

Recall the safest TypeScript moves for untrusted data boundaries.

typescript-basics5 min read

mixed-card deck battlecard comparison card Recall What type should untrusted JSON start as? Think before property reads. unknown unknown accepts the value but blocks unsafe use until a guard, parser, or check narrows it. Compare unknown vs any at an API boundary Use unknown when the shape is not yet proven. Objection "The API docs guarantee this shape, so a cast is enough." Raw data enters through JSON, a webhook, storage, or a URL. Your line The docs are the expected contract; the guard is the runtime receipt. Let's check the fields this function actually uses. A type assertion changes…

Read the full lesson

Sign up free: one personalized lesson every day, matched to your role and goals.

← Back to library

Contact us