From 9946228aaaa44a20f2149f00885a2bec72c9bc41 Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 8 Mar 2019 10:41:10 +0900 Subject: [PATCH 1/2] Conform flow type declarations to TypeScript type definitions. --- decls/i18n.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/decls/i18n.js b/decls/i18n.js index e6d8dcdd6..01cbbc381 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,6 +117,7 @@ declare interface I18n { setNumberFormat (locale: Locale, format: NumberFormat): void, mergeNumberFormat (locale: Locale, format: NumberFormat): void, n (value: number, ...args: any): NumberFormatResult, + getChoiceIndex: (choice: number, choicesLength: number) => number, pluralizationRules: { [lang: string]: (choice: number, choicesLength: number) => number }, From 72c9803d8b0e780a932de69824f66b10d8a43230 Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 8 Mar 2019 11:56:43 +0900 Subject: [PATCH 2/2] Use explicit type instead of anonymous type. --- decls/i18n.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/decls/i18n.js b/decls/i18n.js index 01cbbc381..cb4764b1b 100644 --- a/decls/i18n.js +++ b/decls/i18n.js @@ -118,9 +118,7 @@ declare interface I18n { mergeNumberFormat (locale: Locale, format: NumberFormat): void, n (value: number, ...args: any): NumberFormatResult, getChoiceIndex: (choice: number, choicesLength: number) => number, - pluralizationRules: { - [lang: string]: (choice: number, choicesLength: number) => number - }, + pluralizationRules: PluralizationRules, preserveDirectiveContent: boolean };