Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing type declarations in flow type #529

Merged
merged 2 commits into from
Mar 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions decls/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
};

Expand Down