Skip to main content
Urbicon UI

Type Safety

Keys and their parameters flow from the en bundle straight into the hook's t — typos and missing params are compile errors, not runtime surprises.

Key inference

createPackageI18n is generic over the en bundle (declared <const T>). With as const — or a plain literal object — the key type flows straight through to the hook's t, so keys autocomplete and typos are compile errors.

Loading...
Loading syntax highlighting...

Parameter inference

Parameters are extracted from the {{…}} placeholders in each string. A key with placeholders requires those params; a key without them takes none.

Loading...
Loading syntax highlighting...

Eager vs. lazy parity

Additional eager locales are checked against the en structure, so a missing or misspelled key in de is a compile error too — key parity by construction. For lazy locales the bundle isn't visible to the type-checker, so parity becomes a runtime check; pair it with validatePackageTranslations in a test.

Loading...
Loading syntax highlighting...

Deep-key utilities

The same machinery that types the keys is exported for your own tooling — the DeepKeys / DeepValue types and their runtime counterparts. Useful for building key diffs, custom validators, or typed config readers.

Loading...
Loading syntax highlighting...

Deprecations

createTypedPackage is deprecatedcreatePackageI18n gives the same type safety while also registering the bundles, so there's no reason to use the older two-step form.

Loading...
Loading syntax highlighting...