React
Type Safety
This page explains how type safety is enabled in a React project.
See: Type Safety
Integration Steps
♯1 Generate Types
This section reuses the same translation content structure from the React Quick Start .
Type definitions are generated using the CLI generate command.
The translation file corresponding to defaultLocale is used as the baseline for type inference.
npx intor-cli generate --message-file messages/en/index.json
If translation content is defined directly in the config (Static Import), or loaded via a Loader, the CLI can automatically infer the translation source, so no additional message file needs to be specified.
npx intor-cli generate
After execution, a .intor directory will be created at the project root, containing type definitions inferred from the translation content.
♯2 Configure tsconfig.app.json
Update tsconfig.app.json to include .intor/**/*.d.ts
so that TypeScript can properly load the generated types:
tsconfig.app.jsonM
{ // ... "include": [ // ... ".intor/**/*.d.ts" ] }