07fd7bce64
* Import of Intl.Locale from #39664 * Handle updating es2020.intl and add es2021 for new DateTimeFormatOptions options - re: #39664 * Extends DateTimeFormatOptions for new Intl APIs - re: #45420 * Handle migrating Intl.NumberFormat.formatToParts to es2018 (keeping esnext.intl around) * Adds Intl.DisplayNames to es2020 - re: #44022 * Remove attributes added in es2021 from es2020 - re: #42944 * Add a reference to es2021 in the command line parser * Adds some docs about the lib files * Baselines * Allow undefined in Intl inputs to allow for ergonomic usage of exactOptionalPropertyTypes - see #45652 * Adds some tests covering the APIs * Apply suggestions from code review Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> * Handle PR feedback * More review improvements Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
declare namespace Intl {
|
|
|
|
// http://cldr.unicode.org/index/cldr-spec/plural-rules#TOC-Determining-Plural-Categories
|
|
type LDMLPluralRule = "zero" | "one" | "two" | "few" | "many" | "other";
|
|
type PluralRuleType = "cardinal" | "ordinal";
|
|
|
|
interface PluralRulesOptions {
|
|
localeMatcher?: "lookup" | "best fit" | undefined;
|
|
type?: PluralRuleType | undefined;
|
|
minimumIntegerDigits?: number | undefined;
|
|
minimumFractionDigits?: number | undefined;
|
|
maximumFractionDigits?: number | undefined;
|
|
minimumSignificantDigits?: number | undefined;
|
|
maximumSignificantDigits?: number | undefined;
|
|
}
|
|
|
|
interface ResolvedPluralRulesOptions {
|
|
locale: string;
|
|
pluralCategories: LDMLPluralRule[];
|
|
type: PluralRuleType;
|
|
minimumIntegerDigits: number;
|
|
minimumFractionDigits: number;
|
|
maximumFractionDigits: number;
|
|
minimumSignificantDigits?: number;
|
|
maximumSignificantDigits?: number;
|
|
}
|
|
|
|
interface PluralRules {
|
|
resolvedOptions(): ResolvedPluralRulesOptions;
|
|
select(n: number): LDMLPluralRule;
|
|
}
|
|
|
|
const PluralRules: {
|
|
new (locales?: string | string[], options?: PluralRulesOptions): PluralRules;
|
|
(locales?: string | string[], options?: PluralRulesOptions): PluralRules;
|
|
|
|
supportedLocalesOf(locales: string | string[], options?: { localeMatcher?: "lookup" | "best fit" }): string[];
|
|
};
|
|
|
|
type ES2018NumberFormatPartType = "literal" | "nan" | "infinity" | "percent" | "integer" | "group" | "decimal" | "fraction" | "plusSign" | "minusSign" | "percentSign" | "currency" | "code" | "symbol" | "name";
|
|
interface NumberFormatPart {
|
|
type: ES2018NumberFormatPartType;
|
|
value: string;
|
|
}
|
|
|
|
interface NumberFormat {
|
|
formatToParts(number?: number | bigint): NumberFormatPart[];
|
|
}
|
|
}
|