Type Assertions (as, satisfies, as const) in TypeScript

From the TypeScript cheat sheet · Type Operations · verified Jul 2026

Type Assertions (as, satisfies, as const)

Tell the compiler about types it cannot infer automatically

typescript
// as — assert a type
const input = document.getElementById("name") as HTMLInputElement;

// satisfies — validate without widening
const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
} satisfies Record<string, string | number[]>;

// as const — narrow to literal types
const routes = ["home", "about", "contact"] as const;
💡 satisfies validates WITHOUT widening — you keep literal types and autocomplete
⚡ as const is perfect for config objects, routes, and enum-like arrays
📌 Avoid "as" when possible — it overrides the compiler and hides real errors
🟢 typeof ARRAY[number] extracts a union of all values from an as const array
assatisfiesas-constassertion

More TypeScript tasks

Back to the full TypeScript cheat sheet