Dev Helpers

TypeScript / Mapped types

Require all partial settings

Dev Helpers · June 7, 2026

A partial input and a complete configuration serve different callers. Fill required values at one boundary so downstream code can rely on them.

Worked example

type Settings = { theme: string; limit: number; debug: boolean };
const settings: Settings = { theme: "dark", limit: 4, debug: false };
console.log(((v: Required<Partial<Settings>>) => v.debug)(settings));

Result

false

Implementation notes

Spreading an input object after defaults can overwrite a default with explicit undefined. Define what an explicitly missing value should mean.

Try it yourself

Omit each optional input in turn and inspect the resolved settings.

Open the TypeScript example →

Editorial date June 7, 2026 · Published December 6, 2026

Related articles

Reject fractional cent amounts

A numeric type cannot by itself guarantee whole cents. Validate integrality where money enters the typed part of the application.

Infer route names from a registry

A route registry can drive both lookup and allowed route names. Type the keys from the registry so a removed route cannot survive in a separate union.