i18next 22.0.2 → 22.0.4

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.
@@ -1 +1 @@
1
- {"type":"module","version":"22.0.2"}
1
+ {"type":"module","version":"22.0.4"}
package/index.d.ts CHANGED
@@ -824,7 +824,7 @@ type TypeOptionsFallback<TranslationValue, Option, MatchingValue> = Option exten
824
824
  /**
825
825
  * Checks if user has enabled `returnEmptyString` and `returnNull` options to retrieve correct values.
826
826
  */
827
- interface CustomTypeParameters {
827
+ interface CustomTypeParameters {
828
828
  returnNull?: boolean;
829
829
  returnEmptyString?: boolean;
830
830
  }
@@ -860,13 +860,9 @@ type NormalizeMultiReturn<T, V> = V extends `${infer N}:${infer R}`
860
860
  : never
861
861
  : never;
862
862
 
863
- export type DefaultTFuncReturn =
864
- | string
865
- | object
866
- | TFunctionDetailedResult
867
- | Array<string | object>
868
- | undefined
869
- | null;
863
+ export type DefaultTFuncReturn = string | undefined | null;
864
+
865
+ export type DefaultTFuncReturnWithObject = DefaultTFuncReturn | object | Array<string | object>;
870
866
 
871
867
  export type TFuncReturn<
872
868
  N,
@@ -892,7 +888,7 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
892
888
  ): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
893
889
  <
894
890
  TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
895
- TDefaultResult extends DefaultTFuncReturn = object,
891
+ TDefaultResult extends DefaultTFuncReturnWithObject = object,
896
892
  TInterpolationMap extends object = StringMap,
897
893
  >(
898
894
  key: TKeys | TKeys[],
@@ -908,7 +904,7 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
908
904
  ): TFunctionDetailedResult<TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>>;
909
905
  <
910
906
  TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
911
- TDefaultResult extends DefaultTFuncReturn = object,
907
+ TDefaultResult extends DefaultTFuncReturnWithObject = object,
912
908
  TInterpolationMap extends object = StringMap,
913
909
  >(
914
910
  key: TKeys | TKeys[],
@@ -975,6 +971,10 @@ export class ResourceStore {
975
971
  export interface Formatter {
976
972
  init(services: Services, i18nextOptions: InitOptions): void;
977
973
  add(name: string, fc: (value: any, lng: string | undefined, options: any) => string): void;
974
+ addCached(
975
+ name: string,
976
+ fc: (lng: string | undefined, options: any) => (value: any) => string,
977
+ ): void;
978
978
  format: FormatFunction;
979
979
  }
980
980
 
@@ -1184,12 +1184,20 @@ export interface i18n {
1184
1184
  *
1185
1185
  * Accepts optional keyPrefix that will be automatically applied to returned t function.
1186
1186
  */
1187
- getFixedT(
1187
+ getFixedT<N extends Namespace = DefaultNamespace, TKPrefix extends KeyPrefix<N> = undefined>(
1188
1188
  lng: string | readonly string[],
1189
- ns?: string | readonly string[],
1190
- keyPrefix?: string,
1191
- ): TFunction;
1192
- getFixedT(lng: null, ns: string | readonly string[] | null, keyPrefix?: string): TFunction;
1189
+ ns?: N,
1190
+ keyPrefix?: TKPrefix,
1191
+ ): TFunction<N, TKPrefix>;
1192
+ getFixedT<
1193
+ N extends Namespace | null,
1194
+ TKPrefix extends KeyPrefix<ActualNS>,
1195
+ ActualNS extends Namespace = N extends null ? DefaultNamespace : N,
1196
+ >(
1197
+ lng: null,
1198
+ ns: N,
1199
+ keyPrefix?: TKPrefix,
1200
+ ): TFunction<ActualNS, TKPrefix>;
1193
1201
 
1194
1202
  /**
1195
1203
  * Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next",
3
- "version": "22.0.2",
3
+ "version": "22.0.4",
4
4
  "description": "i18next internationalization framework",
5
5
  "main": "./dist/cjs/i18next.js",
6
6
  "module": "./dist/esm/i18next.js",