gt-react 10.4.1 → 10.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -56,6 +56,7 @@ type _Message = {
56
56
  $_hash?: string;
57
57
  };
58
58
  type _Messages = _Message[];
59
+ type MFunctionType = <T extends string | null | undefined>(encodedMsg: T, options: Record<string, any>) => T extends string ? string : T;
59
60
 
60
61
  type TranslateIcuCallback = (params: {
61
62
  source: string;
@@ -79,7 +80,7 @@ type GTContextType = {
79
80
  registerIcuForTranslation: TranslateIcuCallback;
80
81
  registerJsxForTranslation: TranslateChildrenCallback;
81
82
  _tFunction: (message: string, options?: InlineTranslationOptions, preloadedTranslations?: Translations) => string;
82
- _mFunction: (message: string, options?: Record<string, any>, preloadedTranslations?: Translations) => string;
83
+ _mFunction: <T extends string | null | undefined>(encodedMsg: T, options?: Record<string, any>, preloadedTranslations?: Translations) => T extends string ? string : T;
83
84
  _filterMessagesForPreload: (_messages: _Messages) => _Messages;
84
85
  _preloadMessages: (_messages: _Messages) => Promise<Translations>;
85
86
  _dictionaryFunction: (id: string, options?: DictionaryTranslationOptions) => string;
@@ -153,7 +154,7 @@ declare function msg(message: string, options?: InlineTranslationOptions): strin
153
154
  * @param encodedMsg The message to decode.
154
155
  * @returns The decoded message, or the input if it cannot be decoded.
155
156
  */
156
- declare function decodeMsg(encodedMsg: string): string;
157
+ declare function decodeMsg<T extends string | null | undefined>(encodedMsg: T): T;
157
158
  /**
158
159
  * Decodes the options from an encoded message.
159
160
  * @param encodedMsg The message to decode.
@@ -792,6 +793,6 @@ declare function useLocaleDirection(locale?: string): 'ltr' | 'rtl';
792
793
  * const m = useMessages();
793
794
  * m(encodedMessage) // returns "My name is Brian" translated
794
795
  */
795
- declare function useMessages(_messages?: _Messages): (encodedMsg: string, options?: Record<string, any>) => string;
796
+ declare function useMessages(_messages?: _Messages): MFunctionType;
796
797
 
797
798
  export { Branch, ClientProvider, Currency, DateTime, GTContext, GTProvider, LocaleSelector, Num, Plural, RegionSelector, T, Var, decodeMsg, decodeOptions, msg, renderVariable, useDefaultLocale, useGT, useGTClass, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useRuntimeTranslation, useSetLocale, useTranslations };