0Pricing
TypeScript Academy · Lesson

Locale-Aware Type Inference

Ensure all locales share the same key structure.

Locale-Aware Type Inference

An app ships multiple locales (en, tr, de...). We want a type that errors when any locale is missing keys present in the base, so translations never silently fall out of sync.

A Base Locale

Pick one locale (usually en) as the canonical key structure. Every other locale must match its shape.

const en = {
  greeting: "Hello",
  cart: { empty: "Empty", checkout: "Checkout" },
} as const;

type Base = typeof en;

All lessons in this course

  1. Typing Translation Keys
  2. Interpolation Type Safety
  3. Pluralization with Types
  4. Locale-Aware Type Inference
← Back to TypeScript Academy