i18next 22.3.0 → 22.4.1
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/esm/package.json +1 -1
- package/index.d.ts +67 -23
- package/package.json +1 -1
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"22.
|
|
1
|
+
{"type":"module","version":"22.4.1"}
|
package/index.d.ts
CHANGED
|
@@ -878,64 +878,104 @@ export type TFuncReturn<
|
|
|
878
878
|
: NormalizeReturn<T[N], KeysWithSeparator<TKPrefix, TKeys>>
|
|
879
879
|
: TDefaultResult;
|
|
880
880
|
|
|
881
|
-
export interface TFunction<
|
|
881
|
+
export interface TFunction<
|
|
882
|
+
N extends Namespace | null = DefaultNamespace,
|
|
883
|
+
TKPrefix = undefined,
|
|
884
|
+
ActualNS extends Namespace = N extends null ? DefaultNamespace : N,
|
|
885
|
+
> {
|
|
886
|
+
// just key without options etc...
|
|
882
887
|
<
|
|
883
|
-
TKeys extends TFuncKey<
|
|
888
|
+
TKeys extends TFuncKey<PassedNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
884
889
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
885
890
|
TInterpolationMap extends object = StringMap,
|
|
891
|
+
PassedNS extends Namespace = N extends string ? N : N extends unknown ? DefaultNamespace : N,
|
|
886
892
|
>(
|
|
887
893
|
key: TKeys | TKeys[],
|
|
888
|
-
): TFuncReturn<
|
|
894
|
+
): TFuncReturn<PassedNS, TKeys, TDefaultResult, TKPrefix>;
|
|
895
|
+
|
|
896
|
+
// with returnDetails: true, returnObjects: true
|
|
889
897
|
<
|
|
890
|
-
TKeys extends TFuncKey<
|
|
898
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
891
899
|
TDefaultResult extends DefaultTFuncReturnWithObject = object,
|
|
892
900
|
TInterpolationMap extends object = StringMap,
|
|
893
901
|
>(
|
|
894
902
|
key: TKeys | TKeys[],
|
|
895
|
-
options
|
|
896
|
-
): TFunctionDetailedResult<TFuncReturn<
|
|
903
|
+
options: TOptions<TInterpolationMap> & { returnDetails: true; returnObjects: true },
|
|
904
|
+
): TFunctionDetailedResult<TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>>;
|
|
905
|
+
|
|
906
|
+
// with returnDetails: true
|
|
897
907
|
<
|
|
898
|
-
TKeys extends TFuncKey<
|
|
908
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
899
909
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
900
910
|
TInterpolationMap extends object = StringMap,
|
|
901
911
|
>(
|
|
902
912
|
key: TKeys | TKeys[],
|
|
903
|
-
options
|
|
904
|
-
): TFunctionDetailedResult<TFuncReturn<
|
|
913
|
+
options: TOptions<TInterpolationMap> & { returnDetails: true },
|
|
914
|
+
): TFunctionDetailedResult<TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>>;
|
|
915
|
+
|
|
916
|
+
// with returnObjects: true
|
|
905
917
|
<
|
|
906
|
-
TKeys extends TFuncKey<
|
|
918
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
907
919
|
TDefaultResult extends DefaultTFuncReturnWithObject = object,
|
|
908
920
|
TInterpolationMap extends object = StringMap,
|
|
909
921
|
>(
|
|
910
922
|
key: TKeys | TKeys[],
|
|
911
|
-
options
|
|
912
|
-
): TFuncReturn<
|
|
923
|
+
options: TOptions<TInterpolationMap> & { returnObjects: true },
|
|
924
|
+
): TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>;
|
|
925
|
+
|
|
926
|
+
// with passed ns prop in options
|
|
913
927
|
<
|
|
914
|
-
TKeys extends TFuncKey<
|
|
928
|
+
TKeys extends TFuncKey<PassedNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
915
929
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
916
930
|
TInterpolationMap extends object = StringMap,
|
|
931
|
+
PassedNS extends Namespace = N extends string ? N : N extends null ? DefaultNamespace : N,
|
|
917
932
|
>(
|
|
918
933
|
key: TKeys | TKeys[],
|
|
919
|
-
options
|
|
920
|
-
): TFuncReturn<
|
|
934
|
+
options: TOptions<TInterpolationMap> & { ns: PassedNS },
|
|
935
|
+
): TFuncReturn<PassedNS, TKeys, TDefaultResult, TKPrefix>;
|
|
936
|
+
|
|
937
|
+
// with options
|
|
921
938
|
<
|
|
922
|
-
TKeys extends TFuncKey<
|
|
939
|
+
TKeys extends TFuncKey<UsedNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
923
940
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
924
941
|
TInterpolationMap extends object = StringMap,
|
|
925
|
-
PassedNS extends Namespace = N extends null ? DefaultNamespace : N,
|
|
942
|
+
PassedNS extends Namespace = N extends string ? N : N extends null ? DefaultNamespace : N,
|
|
943
|
+
PassedOpt extends TOptions<TInterpolationMap> = TOptions<TInterpolationMap>,
|
|
944
|
+
UsedNS extends Namespace = Pick<PassedOpt, 'ns'> extends { ns: string }
|
|
945
|
+
? PassedNS
|
|
946
|
+
: ActualNS | DefaultNamespace,
|
|
926
947
|
>(
|
|
927
948
|
key: TKeys | TKeys[],
|
|
928
|
-
options:
|
|
929
|
-
): TFuncReturn<
|
|
949
|
+
options: PassedOpt,
|
|
950
|
+
): TFuncReturn<UsedNS, TKeys, TDefaultResult, TKPrefix>;
|
|
951
|
+
|
|
952
|
+
// defaultValue
|
|
930
953
|
<
|
|
931
|
-
TKeys extends TFuncKey<
|
|
954
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
932
955
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
933
956
|
TInterpolationMap extends object = StringMap,
|
|
934
957
|
>(
|
|
935
958
|
key: TKeys | TKeys[],
|
|
936
959
|
defaultValue?: string,
|
|
937
960
|
options?: TOptions<TInterpolationMap> | string,
|
|
938
|
-
): TFuncReturn<
|
|
961
|
+
): TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>;
|
|
962
|
+
<
|
|
963
|
+
TDefaultResult extends DefaultTFuncReturn = string,
|
|
964
|
+
TInterpolationMap extends object = StringMap,
|
|
965
|
+
>(
|
|
966
|
+
key: string | string[],
|
|
967
|
+
defaultValue: string,
|
|
968
|
+
options?: TOptions<TInterpolationMap> | string,
|
|
969
|
+
): TFuncReturn<ActualNS, string, TDefaultResult, TKPrefix>;
|
|
970
|
+
|
|
971
|
+
// defaultValue via options
|
|
972
|
+
<
|
|
973
|
+
TDefaultResult extends DefaultTFuncReturn = string,
|
|
974
|
+
TInterpolationMap extends object = StringMap,
|
|
975
|
+
>(
|
|
976
|
+
key: string | string[],
|
|
977
|
+
options: TOptions<TInterpolationMap> & { defaultValue: string },
|
|
978
|
+
): TFuncReturn<ActualNS, string, TDefaultResult, TKPrefix>;
|
|
939
979
|
}
|
|
940
980
|
|
|
941
981
|
export interface Resource {
|
|
@@ -1195,11 +1235,15 @@ export interface i18n {
|
|
|
1195
1235
|
*
|
|
1196
1236
|
* Accepts optional keyPrefix that will be automatically applied to returned t function.
|
|
1197
1237
|
*/
|
|
1198
|
-
getFixedT<
|
|
1238
|
+
getFixedT<
|
|
1239
|
+
N extends Namespace | null,
|
|
1240
|
+
TKPrefix extends KeyPrefix<ActualNS> = undefined,
|
|
1241
|
+
ActualNS extends Namespace = N extends null ? DefaultNamespace : N,
|
|
1242
|
+
>(
|
|
1199
1243
|
lng: string | readonly string[],
|
|
1200
1244
|
ns?: N,
|
|
1201
1245
|
keyPrefix?: TKPrefix,
|
|
1202
|
-
): TFunction<
|
|
1246
|
+
): TFunction<ActualNS, TKPrefix>;
|
|
1203
1247
|
getFixedT<
|
|
1204
1248
|
N extends Namespace | null,
|
|
1205
1249
|
TKPrefix extends KeyPrefix<ActualNS>,
|