UNPKG

vite-plugin-vue-i18n-typescript

Version:

Type-safe Vue i18n translations. Auto-generates TypeScript types from JSON locale files. Catch translation errors at compile time with full IDE autocomplete.

44 lines (40 loc) 1.62 kB
import './vite-env-override-components.cjs'; import { J as JSONObject, G as GenerationOptions } from './types-D-t7iqK-.cjs'; export { C as CustomLogger, c as GenerateTypesOptions, d as GenerateTypesResult, b as JSONArray, a as JSONValue, V as VirtualKeysDtsOptions } from './types-D-t7iqK-.cjs'; import { CombinedMessages } from './api.cjs'; export { generateI18nTypes } from './api.cjs'; export { vitePluginVueI18nTypescript as default } from './plugin.cjs'; import 'vue-i18n'; import 'vite'; type MessageNode = { type: number; loc?: { source?: string; }; static?: string; body?: any; cases?: any[]; items?: any[]; }; /** * Structure-normalizing extractor. Removes AST-ish metadata, unwraps translation bodies, * and preserves shape while pruning noise. It's defensive and avoids repeated lookups. */ declare function extractJson<T extends Record<string, any> | MessageNode>(obj: T): any; /** * Collect dot-notated leaf paths of an object. * - Primitives produce their full path. * - Arrays count as leaves (the array path is included) AND their items are traversed, * producing index paths (e.g., "c", "c.0", "c.1"). * Example: * { a: { b: 1 }, c: ['test', 'asdf'] } => ["a.b", "c", "c.0", "c.1"] */ declare function getJsonLeafPaths(obj: Record<string, unknown>): string[]; /** * Create .d.ts content for type definitions only */ declare function toTypesContent(params: { combinedMessages: CombinedMessages<string, JSONObject>; config?: GenerationOptions; }): string; export { GenerationOptions, JSONObject, extractJson, getJsonLeafPaths, toTypesContent };