fix(i18n): support FormattedString

totally forgot about it
This commit is contained in:
teidesu 2022-07-19 03:11:08 +03:00
parent ebe9786987
commit 0330efd4dc

View file

@ -1,9 +1,12 @@
import { ParsedUpdate } from '@mtcute/client'
import { FormattedString, ParsedUpdate } from '@mtcute/client'
type Values<T> = T[keyof T]
type SafeGet<T, K extends string> = T extends Record<K, any> ? T[K] : never
export type I18nValue = string | ((...args: any[]) => string)
export type I18nValue =
| string
| FormattedString<any>
| ((...args: any[]) => string | FormattedString<any>)
type NestedKeysDelimited<T> = Values<{
[key in Extract<keyof T, string>]: T[key] extends I18nValue
@ -28,7 +31,7 @@ export type MtcuteI18nFunction<Strings> = <
lang: ParsedUpdate['data'] | string | null,
key: K,
...params: ExtractParameter<Strings, K>
) => string
) => string | FormattedString<any>
export type OtherLanguageWrap<Strings> = {
[key in keyof Strings]?: Strings[key] extends I18nValue