Quick ref: boundary types
Recall the safest TypeScript moves for untrusted data boundaries.
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…
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in