From 41737648954205c079626d9cd737d48d08ab3b7a Mon Sep 17 00:00:00 2001 From: TATSUNO Yasuhiro Date: Fri, 8 Mar 2019 12:19:19 +0900 Subject: [PATCH] :zap: improvement(flowtype): Fix missing type declarations in flow type (#529) by @exoego * Conform flow type declarations to TypeScript type definitions. * Use explicit type instead of anonymous type. --- decls/i18n.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/decls/i18n.js b/decls/i18n.js index e6d8dcdd6..cb4764b1b 100644 --- a/decls/i18n.js +++ b/decls/i18n.js @@ -63,9 +63,7 @@ declare type I18nOptions = { sync?: boolean, silentTranslationWarn?: boolean, silentFallbackWarn?: boolean, - pluralizationRules?: { - [lang: string]: (choice: number, choicesLength: number) => number, - }, + pluralizationRules?: PluralizationRules, preserveDirectiveContent?: boolean, }; @@ -74,6 +72,10 @@ declare type IntlAvailability = { numberFormat: boolean }; +declare type PluralizationRules = { + [lang: string]: (choice: number, choicesLength: number) => number, +} + declare interface I18n { static install: () => void, // for Vue plugin interface static version: string, @@ -85,6 +87,7 @@ declare interface I18n { set fallbackLocale (locale: Locale): void, get messages (): LocaleMessages, get dateTimeFormats (): DateTimeFormats, + get numberFormats (): NumberFormats, get availableLocales (): Locale[], get missing (): ?MissingHandler, set missing (handler: MissingHandler): void, @@ -94,6 +97,11 @@ declare interface I18n { set silentTranslationWarn (silent: boolean): void, get silentFallbackWarn (): boolean, set silentFallbackWarn (slient: boolean): void, + get pluralizationRules (): PluralizationRules, + set pluralizationRules (rules: PluralizationRules): void, + get preserveDirectiveContent (): boolean, + set preserveDirectiveContent (preserve: boolean): void, + getLocaleMessage (locale: Locale): LocaleMessageObject, setLocaleMessage (locale: Locale, message: LocaleMessageObject): void, mergeLocaleMessage (locale: Locale, message: LocaleMessageObject): void, @@ -109,9 +117,8 @@ declare interface I18n { setNumberFormat (locale: Locale, format: NumberFormat): void, mergeNumberFormat (locale: Locale, format: NumberFormat): void, n (value: number, ...args: any): NumberFormatResult, - pluralizationRules: { - [lang: string]: (choice: number, choicesLength: number) => number - }, + getChoiceIndex: (choice: number, choicesLength: number) => number, + pluralizationRules: PluralizationRules, preserveDirectiveContent: boolean };