diff options
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/TranslationsDictionary.d.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/types/TranslationsDictionary.d.ts b/src/types/TranslationsDictionary.d.ts index 5033ecd..47ee7f4 100644 --- a/src/types/TranslationsDictionary.d.ts +++ b/src/types/TranslationsDictionary.d.ts @@ -1,12 +1,15 @@ import type { defaultLocale } from '$i18n/locales'; import type Locale from './Locale'; -export type Translation<Params> = (params: { [key in keyof Params]: string }) => string; +export type Translation<ParamsHash extends object> = (params: ParamsHash) => string; +export type LocalesTranslationHash<ParamsHash extends object> = { + [locale in Locale]?: Translation<ParamsHash>; +} & { + [locale in typeof defaultLocale]: Translation<ParamsHash>; +}; export type TranslationsDictionary<Raw> = { - readonly [key in keyof Raw]: { - [locale in Locale]?: Translation<Parameters<Raw[key][typeof defaultLocale]>[0]>; - } & { - [locale in typeof defaultLocale]: Translation<Parameters<Raw[key][typeof defaultLocale]>[0]>; - }; + readonly [key in keyof Raw]: LocalesTranslationHash< + Parameters<Raw[key][typeof defaultLocale]>[0] + >; }; |
