fix(i18n): enforce same arg types in OtherLanguageWrap

This commit is contained in:
teidesu 2022-09-12 15:28:45 +03:00
parent b7d0b85a15
commit d4040a768f
2 changed files with 3 additions and 2 deletions

View file

@ -62,8 +62,8 @@ export type MtcuteI18nFunction<Strings, Input> = <
* other than the primary one. Used to provide type safety.
*/
export type OtherLanguageWrap<Strings> = {
[key in keyof Strings]?: Strings[key] extends I18nValue
? I18nValue
[key in keyof Strings]?: Strings[key] extends I18nValue<infer A>
? I18nValue<A>
: Strings[key] extends Record<string, any>
? OtherLanguageWrap<Strings[key]>
: never

View file

@ -18,6 +18,7 @@ const ru: OtherLanguageWrap<typeof en> = {
basic: {
hello: 'Привет',
// world: () => 'Мир',
// welcome: (name: number) => `Привет ${name}`,
welcome: (name: string) => `Привет ${name}`,
},
}