SPB Git

Repository Public

types.ts 903 B 19 lines typescript

1import type { fr } from "./fr";23export type Plural = { one: string; other: string };4export type Dict = typeof fr;5/** Same shape as the French dictionary with free string values: the type of every other locale. */6export type Shape<T> = { [K in keyof T]: T[K] extends string ? string : Shape<T[K]> };78type Join<P extends string, K extends string> = P extends "" ? K : `${P}.${K}`;9export type LeafKeys<T, P extends string = ""> = {10  [K in keyof T & string]: T[K] extends string ? Join<P, K> : T[K] extends Plural ? never : LeafKeys<T[K], Join<P, K>>;11}[keyof T & string];12export type PluralKeys<T, P extends string = ""> = {13  [K in keyof T & string]: T[K] extends string ? never : T[K] extends Plural ? Join<P, K> : PluralKeys<T[K], Join<P, K>>;14}[keyof T & string];1516export type TKey = LeafKeys<Dict>;17export type TPluralKey = PluralKeys<Dict>;18export type Vars = Record<string, string | number>;19
Files main
Menu

Theme