@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
14 lines (13 loc) • 733 B
TypeScript
import type nb from "./locales/nb";
type NestedKeyOf<ObjectType extends object> = {
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
}[keyof ObjectType & (string | number)];
export type TFunction<T extends Component> = (keypath: NestedKeyOf<Translations[T]>, replacements?: Record<string, string | number>) => string;
type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export type Translations = typeof nb;
export type PartialTranslations = RecursivePartial<Translations>;
export type Component = keyof Translations;
export type ComponentTranslation<T extends Component> = RecursivePartial<Translations[T]>;
export {};