type Nully = undefined | null ; type NamespaceValues = string | ReadonlyArray < string > ; export type NamespaceMessages = Readonly < Record < string , NamespaceValues | undefined | null > > ; type RetVal < Value , Fallback > = Value extends Nully ? Fallback : Value extends Exclude < Value , Nully > ? Value : Exclude < Value , Nully > | Fallback ; export type NamespaceGetter < M extends NamespaceMessages > = { < K extends keyof M > ( key , fallback ? ) : RetVal < M [ K ] , K > ; < K extends keyof M , F extends NamespaceValues > ( key , fallback ) : RetVal < M [ K ] , F > ; deprecated ( key , fallback ? ) : any ; } ; export function useNamespaceStrict < M extends NamespaceMessages > ( namespace = { } as M ) { return ( key , fallback ? ) => { return namespace [ key ] ?? fallback ?? key ; } ; } export function useNamespace ( namespace = { } ) { return ( key , fallback ? ) => { return namespace [ key as keyof typeof namespace ] ?? fallback ?? key ; } ; }