SvelteKit

Type Safety

This page explains how type safety is enabled in a SvelteKit project.

See: Type Safety


Integration Steps

♯1 Generate Types

This section reuses the same translation content structure from the SvelteKit 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.json

Update tsconfig.json to include .intor/**/*.d.ts
so that TypeScript can properly load the generated types:

tsconfig.json
M
{
  // ...
  "include": [
    // ...
    ".intor/**/*.d.ts"
  ]
}