i18next: Fix compile errors (#19205)

This commit is contained in:
Andy
2017-08-28 07:51:50 -07:00
committed by GitHub
parent b465332e39
commit eb3a5d2ad9
2 changed files with 13 additions and 14 deletions

View File

@@ -435,21 +435,21 @@ interface CustomOptions {
myVar: string;
}
i18next.t<string, object, KeyList>("friend");
i18next.t<string, object, KeyList>(["friend", "tree"]);
i18next.t<string, CustomOptions, KeyList>("friend", { myVar: "someValue" });
i18next.t<string, CustomOptions, KeyList>(["friend", "tree"], { myVar: "someValue" });
i18next.t<string, CustomOptions>("friend", { myVar: "someValue" });
i18next.t<string, CustomOptions>(["friend", "tree"], { myVar: "someValue" });
i18next.t("friend");
i18next.t(["friend", "tree"]);
i18next.t("friend", { myVar: "someValue" });
i18next.t(["friend", "tree"], { myVar: "someValue" });
i18next.t("friend", { myVar: "someValue" });
i18next.t(["friend", "tree"], { myVar: "someValue" });
const t1: i18next.TranslationFunction = (key: string, options: i18next.TranslationOptions) => "";
const t2: i18next.TranslationFunction<{ value: string }> = (key: string, options: i18next.TranslationOptions) => ({ value: "asd" });
const t3: i18next.TranslationFunction<string, CustomOptions> = (key: string | string[], options: i18next.TranslationOptions<CustomOptions>) => "";
const t4: i18next.TranslationFunction<string, object, KeyList> = (key: KeyList | KeyList[], options: i18next.TranslationOptions) => "";
i18next.exists<boolean, object, KeyList>("friend");
i18next.exists<boolean, object, KeyList>(["friend", "tree"]);
i18next.exists<boolean, CustomOptions, KeyList>("friend", { myVar: "someValue" });
i18next.exists<boolean, CustomOptions, KeyList>(["friend", "tree"], { myVar: "someValue" });
i18next.exists<boolean, CustomOptions>("friend", { myVar: "someValue" });
i18next.exists<boolean, CustomOptions>(["friend", "tree"], { myVar: "someValue" });
i18next.exists("friend");
i18next.exists(["friend", "tree"]);
i18next.exists("friend", { myVar: "someValue" });
i18next.exists(["friend", "tree"], { myVar: "someValue" });
i18next.exists("friend", { myVar: "someValue" });
i18next.exists(["friend", "tree"], { myVar: "someValue" });

View File

@@ -396,8 +396,7 @@ declare namespace i18next {
type Callback = (error: any, t: TranslationFunction) => void;
type TranslationFunction<TResult = any, TValues extends object = object, TKeys extends string = string> =
<TMethodResult = TResult, TMethodValues extends object = TValues, TMethodKeys extends string = TKeys>
(key: TMethodKeys | TMethodKeys[], options?: TranslationOptions<TMethodValues>) => TMethodResult;
(key: TKeys | TKeys[], options?: TranslationOptions<TValues>) => TResult;
interface Resource {
[language: string]: ResourceLanguage;