i18next 22.0.0 → 22.0.2

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.0"}
1
+ {"type":"module","version":"22.0.2"}
package/index.d.ts CHANGED
@@ -824,10 +824,15 @@ 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 {
828
+ returnNull?: boolean;
829
+ returnEmptyString?: boolean;
830
+ }
827
831
  export type NormalizeByTypeOptions<
828
832
  TranslationValue,
829
- R = TypeOptionsFallback<TranslationValue, TypeOptions['returnEmptyString'], ''>,
830
- > = TypeOptionsFallback<R, TypeOptions['returnNull'], null>;
833
+ Options extends CustomTypeParameters = TypeOptions,
834
+ R = TypeOptionsFallback<TranslationValue, Options['returnEmptyString'], ''>,
835
+ > = TypeOptionsFallback<R, Options['returnNull'], null>;
831
836
 
832
837
  type StringIfPlural<T> = TypeOptions['jsonFormat'] extends 'v4'
833
838
  ? T extends `${string}_${PluralSuffix}`
@@ -835,7 +840,7 @@ type StringIfPlural<T> = TypeOptions['jsonFormat'] extends 'v4'
835
840
  : never
836
841
  : never;
837
842
 
838
- type NormalizeReturn<
843
+ export type NormalizeReturn<
839
844
  T,
840
845
  V,
841
846
  S extends string | false = TypeOptions['keySeparator'],
@@ -880,14 +885,22 @@ export type TFuncReturn<
880
885
  export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = undefined> {
881
886
  <
882
887
  TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
883
- TDefaultResult extends DefaultTFuncReturn,
888
+ TDefaultResult extends DefaultTFuncReturn = string,
884
889
  TInterpolationMap extends object = StringMap,
885
890
  >(
886
891
  key: TKeys | TKeys[],
887
892
  ): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
888
893
  <
889
894
  TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
890
- TDefaultResult extends DefaultTFuncReturn,
895
+ TDefaultResult extends DefaultTFuncReturn = object,
896
+ TInterpolationMap extends object = StringMap,
897
+ >(
898
+ key: TKeys | TKeys[],
899
+ options?: TOptions<TInterpolationMap> & { returnDetails: true; returnObjects: true },
900
+ ): TFunctionDetailedResult<TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>>;
901
+ <
902
+ TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
903
+ TDefaultResult extends DefaultTFuncReturn = string,
891
904
  TInterpolationMap extends object = StringMap,
892
905
  >(
893
906
  key: TKeys | TKeys[],
@@ -895,7 +908,15 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
895
908
  ): TFunctionDetailedResult<TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>>;
896
909
  <
897
910
  TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
898
- TDefaultResult extends DefaultTFuncReturn,
911
+ TDefaultResult extends DefaultTFuncReturn = object,
912
+ TInterpolationMap extends object = StringMap,
913
+ >(
914
+ key: TKeys | TKeys[],
915
+ options?: TOptions<TInterpolationMap> & { returnObjects: true },
916
+ ): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
917
+ <
918
+ TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
919
+ TDefaultResult extends DefaultTFuncReturn = string,
899
920
  TInterpolationMap extends object = StringMap,
900
921
  >(
901
922
  key: TKeys | TKeys[],
@@ -903,7 +924,7 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
903
924
  ): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
904
925
  <
905
926
  TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
906
- TDefaultResult extends DefaultTFuncReturn,
927
+ TDefaultResult extends DefaultTFuncReturn = string,
907
928
  TInterpolationMap extends object = StringMap,
908
929
  >(
909
930
  key: TKeys | TKeys[],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next",
3
- "version": "22.0.0",
3
+ "version": "22.0.2",
4
4
  "description": "i18next internationalization framework",
5
5
  "main": "./dist/cjs/i18next.js",
6
6
  "module": "./dist/esm/i18next.js",
@@ -102,12 +102,12 @@
102
102
  "watchify": "3.9.0"
103
103
  },
104
104
  "scripts": {
105
- "pretest": "npm run test:typescript && npm run test:custom-typescript && npm run test:typescript:noninterop",
105
+ "pretest": "npm run test:typescript && npm run test:typescript:customtypes && npm run test:typescript:noninterop",
106
106
  "test": "npm run test:new && npm run test:compat",
107
107
  "test:new": "karma start karma.conf.js --singleRun",
108
108
  "test:compat": "karma start karma.backward.conf.js --singleRun",
109
109
  "test:typescript": "tslint --project tsconfig.json",
110
- "test:custom-typescript": "tslint --project test/typescript/custom-types/tsconfig.json",
110
+ "test:typescript:customtypes": "tslint --project test/typescript/custom-types/tsconfig.json",
111
111
  "test:typescript:noninterop": "tslint --project tsconfig.nonEsModuleInterop.json",
112
112
  "tdd": "karma start karma.conf.js",
113
113
  "tdd:compat": "karma start karma.backward.conf.js",