international-types
Advanced tools
Comparing version 0.5.3 to 0.6.0
@@ -20,2 +20,11 @@ export type LocaleValue = string | number | boolean | null | undefined | Date; | ||
export type GetLocaleType<Locales extends ImportedLocales | ExplicitLocales> = Locales extends ImportedLocales ? Awaited<ReturnType<Locales[SomeKey<Locales>]>>['default'] : Locales[SomeKey<Locales>]; | ||
type Join<K, P> = K extends string | number ? P extends string | number ? `${K}${'' extends P ? '' : '.'}${P}` : never : never; | ||
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...0[]]; | ||
type Leaves<T, D extends number = 10> = [D] extends [never] ? never : T extends object ? { | ||
[K in keyof T]-?: Join<K, Leaves<T[K], Prev[D]>>; | ||
}[keyof T] : ''; | ||
type FollowPath<T, P> = P extends `${infer U}.${infer R}` ? U extends keyof T ? FollowPath<T[U], R> : never : P extends keyof T ? T[P] : never; | ||
export type FlattenLocale<Locale extends Record<string, unknown>> = { | ||
[K in Leaves<Locale>]: FollowPath<Locale, K>; | ||
}; | ||
export {}; |
{ | ||
"name": "international-types", | ||
"version": "0.5.3", | ||
"version": "0.6.0", | ||
"description": "Type-safe internationalization (i18n) utility types", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
6085
30