i18next 22.4.0 → 22.4.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.
- package/dist/esm/package.json +1 -1
- package/index.d.ts +66 -27
- package/package.json +1 -1
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"22.4.
|
|
1
|
+
{"type":"module","version":"22.4.2"}
|
package/index.d.ts
CHANGED
|
@@ -878,7 +878,11 @@ 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
|
+
> {
|
|
882
886
|
// just key without options etc...
|
|
883
887
|
<
|
|
884
888
|
TKeys extends TFuncKey<PassedNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
@@ -889,67 +893,98 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
|
|
|
889
893
|
key: TKeys | TKeys[],
|
|
890
894
|
): TFuncReturn<PassedNS, TKeys, TDefaultResult, TKPrefix>;
|
|
891
895
|
|
|
892
|
-
// with returnDetails: true, returnObjects: true
|
|
896
|
+
// with returnDetails: true, returnObjects: true and ns prop in options
|
|
893
897
|
<
|
|
894
|
-
TKeys extends TFuncKey<
|
|
898
|
+
TKeys extends TFuncKey<Namespace, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
895
899
|
TDefaultResult extends DefaultTFuncReturnWithObject = object,
|
|
896
900
|
TInterpolationMap extends object = StringMap,
|
|
901
|
+
PassedNS extends Namespace = N extends string ? N : N extends null ? DefaultNamespace : N,
|
|
897
902
|
>(
|
|
898
903
|
key: TKeys | TKeys[],
|
|
899
|
-
options: TOptions<TInterpolationMap> & {
|
|
900
|
-
|
|
904
|
+
options: TOptions<TInterpolationMap> & {
|
|
905
|
+
ns: PassedNS;
|
|
906
|
+
returnObjects: true;
|
|
907
|
+
returnDetails: true;
|
|
908
|
+
},
|
|
909
|
+
): TFunctionDetailedResult<TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>>;
|
|
910
|
+
|
|
911
|
+
// with returnObjects: true and ns prop in options
|
|
912
|
+
<
|
|
913
|
+
TKeys extends TFuncKey<Namespace, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
914
|
+
TDefaultResult extends DefaultTFuncReturnWithObject = object,
|
|
915
|
+
TInterpolationMap extends object = StringMap,
|
|
916
|
+
PassedNS extends Namespace = N extends string ? N : N extends null ? DefaultNamespace : N,
|
|
917
|
+
>(
|
|
918
|
+
key: TKeys | TKeys[],
|
|
919
|
+
options: TOptions<TInterpolationMap> & { ns: PassedNS; returnObjects: true },
|
|
920
|
+
): TFuncReturn<PassedNS, TKeys, TDefaultResult, TKPrefix>;
|
|
901
921
|
|
|
902
|
-
// with
|
|
922
|
+
// with passed ns prop in options
|
|
903
923
|
<
|
|
904
|
-
TKeys extends TFuncKey<
|
|
924
|
+
TKeys extends TFuncKey<PassedNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
905
925
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
906
926
|
TInterpolationMap extends object = StringMap,
|
|
927
|
+
PassedNS extends Namespace = N extends string ? N : N extends null ? DefaultNamespace : N,
|
|
907
928
|
>(
|
|
908
929
|
key: TKeys | TKeys[],
|
|
909
|
-
options: TOptions<TInterpolationMap> & {
|
|
910
|
-
):
|
|
930
|
+
options: TOptions<TInterpolationMap> & { ns: PassedNS },
|
|
931
|
+
): TFuncReturn<PassedNS, TKeys, TDefaultResult, TKPrefix>;
|
|
911
932
|
|
|
912
|
-
// with returnObjects: true
|
|
933
|
+
// with returnDetails: true, returnObjects: true
|
|
913
934
|
<
|
|
914
|
-
TKeys extends TFuncKey<
|
|
935
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
915
936
|
TDefaultResult extends DefaultTFuncReturnWithObject = object,
|
|
916
937
|
TInterpolationMap extends object = StringMap,
|
|
917
938
|
>(
|
|
918
939
|
key: TKeys | TKeys[],
|
|
919
|
-
options: TOptions<TInterpolationMap> & { returnObjects: true },
|
|
920
|
-
): TFuncReturn<
|
|
940
|
+
options: TOptions<TInterpolationMap> & { returnDetails: true; returnObjects: true },
|
|
941
|
+
): TFunctionDetailedResult<TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>>;
|
|
921
942
|
|
|
922
|
-
// with
|
|
943
|
+
// with returnDetails: true
|
|
923
944
|
<
|
|
924
|
-
TKeys extends TFuncKey<
|
|
945
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
925
946
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
926
947
|
TInterpolationMap extends object = StringMap,
|
|
927
|
-
PassedNS extends Namespace = N extends string ? N : N extends unknown ? DefaultNamespace : N,
|
|
928
948
|
>(
|
|
929
949
|
key: TKeys | TKeys[],
|
|
930
|
-
options: TOptions<TInterpolationMap> & {
|
|
931
|
-
): TFuncReturn<
|
|
950
|
+
options: TOptions<TInterpolationMap> & { returnDetails: true },
|
|
951
|
+
): TFunctionDetailedResult<TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>>;
|
|
952
|
+
|
|
953
|
+
// with returnObjects: true
|
|
954
|
+
<
|
|
955
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
956
|
+
TDefaultResult extends DefaultTFuncReturnWithObject = object,
|
|
957
|
+
TInterpolationMap extends object = StringMap,
|
|
958
|
+
>(
|
|
959
|
+
key: TKeys | TKeys[],
|
|
960
|
+
options: TOptions<TInterpolationMap> & { returnObjects: true },
|
|
961
|
+
): TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>;
|
|
932
962
|
|
|
933
963
|
// with options
|
|
934
964
|
<
|
|
935
|
-
TKeys extends TFuncKey<
|
|
965
|
+
TKeys extends TFuncKey<UsedNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
936
966
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
937
967
|
TInterpolationMap extends object = StringMap,
|
|
968
|
+
PassedNS extends Namespace = N extends string ? N : N extends null ? DefaultNamespace : N,
|
|
969
|
+
PassedOpt extends TOptions<TInterpolationMap> = TOptions<TInterpolationMap>,
|
|
970
|
+
UsedNS extends Namespace = Pick<PassedOpt, 'ns'> extends { ns: string }
|
|
971
|
+
? PassedNS
|
|
972
|
+
: ActualNS | DefaultNamespace,
|
|
938
973
|
>(
|
|
939
974
|
key: TKeys | TKeys[],
|
|
940
|
-
options:
|
|
941
|
-
): TFuncReturn<
|
|
975
|
+
options: PassedOpt,
|
|
976
|
+
): TFuncReturn<UsedNS, TKeys, TDefaultResult, TKPrefix>;
|
|
942
977
|
|
|
943
978
|
// defaultValue
|
|
944
979
|
<
|
|
945
|
-
TKeys extends TFuncKey<
|
|
980
|
+
TKeys extends TFuncKey<ActualNS, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
|
|
946
981
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
947
982
|
TInterpolationMap extends object = StringMap,
|
|
948
983
|
>(
|
|
949
984
|
key: TKeys | TKeys[],
|
|
950
985
|
defaultValue?: string,
|
|
951
986
|
options?: TOptions<TInterpolationMap> | string,
|
|
952
|
-
): TFuncReturn<
|
|
987
|
+
): TFuncReturn<ActualNS, TKeys, TDefaultResult, TKPrefix>;
|
|
953
988
|
<
|
|
954
989
|
TDefaultResult extends DefaultTFuncReturn = string,
|
|
955
990
|
TInterpolationMap extends object = StringMap,
|
|
@@ -957,7 +992,7 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
|
|
|
957
992
|
key: string | string[],
|
|
958
993
|
defaultValue: string,
|
|
959
994
|
options?: TOptions<TInterpolationMap> | string,
|
|
960
|
-
): TFuncReturn<
|
|
995
|
+
): TFuncReturn<ActualNS, string, TDefaultResult, TKPrefix>;
|
|
961
996
|
|
|
962
997
|
// defaultValue via options
|
|
963
998
|
<
|
|
@@ -966,7 +1001,7 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
|
|
|
966
1001
|
>(
|
|
967
1002
|
key: string | string[],
|
|
968
1003
|
options: TOptions<TInterpolationMap> & { defaultValue: string },
|
|
969
|
-
): TFuncReturn<
|
|
1004
|
+
): TFuncReturn<ActualNS, string, TDefaultResult, TKPrefix>;
|
|
970
1005
|
}
|
|
971
1006
|
|
|
972
1007
|
export interface Resource {
|
|
@@ -1226,11 +1261,15 @@ export interface i18n {
|
|
|
1226
1261
|
*
|
|
1227
1262
|
* Accepts optional keyPrefix that will be automatically applied to returned t function.
|
|
1228
1263
|
*/
|
|
1229
|
-
getFixedT<
|
|
1264
|
+
getFixedT<
|
|
1265
|
+
N extends Namespace | null,
|
|
1266
|
+
TKPrefix extends KeyPrefix<ActualNS> = undefined,
|
|
1267
|
+
ActualNS extends Namespace = N extends null ? DefaultNamespace : N,
|
|
1268
|
+
>(
|
|
1230
1269
|
lng: string | readonly string[],
|
|
1231
1270
|
ns?: N,
|
|
1232
1271
|
keyPrefix?: TKPrefix,
|
|
1233
|
-
): TFunction<
|
|
1272
|
+
): TFunction<ActualNS, TKPrefix>;
|
|
1234
1273
|
getFixedT<
|
|
1235
1274
|
N extends Namespace | null,
|
|
1236
1275
|
TKPrefix extends KeyPrefix<ActualNS>,
|