lib.es2018.intl.d.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*! *****************************************************************************
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  4. this file except in compliance with the License. You may obtain a copy of the
  5. License at http://www.apache.org/licenses/LICENSE-2.0
  6. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  8. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  9. MERCHANTABLITY OR NON-INFRINGEMENT.
  10. See the Apache Version 2.0 License for specific language governing permissions
  11. and limitations under the License.
  12. ***************************************************************************** */
  13. /// <reference no-default-lib="true"/>
  14. declare namespace Intl {
  15. // http://cldr.unicode.org/index/cldr-spec/plural-rules#TOC-Determining-Plural-Categories
  16. type LDMLPluralRule = "zero" | "one" | "two" | "few" | "many" | "other";
  17. type PluralRuleType = "cardinal" | "ordinal";
  18. interface PluralRulesOptions {
  19. localeMatcher?: "lookup" | "best fit" | undefined;
  20. type?: PluralRuleType | undefined;
  21. minimumIntegerDigits?: number | undefined;
  22. minimumFractionDigits?: number | undefined;
  23. maximumFractionDigits?: number | undefined;
  24. minimumSignificantDigits?: number | undefined;
  25. maximumSignificantDigits?: number | undefined;
  26. }
  27. interface ResolvedPluralRulesOptions {
  28. locale: string;
  29. pluralCategories: LDMLPluralRule[];
  30. type: PluralRuleType;
  31. minimumIntegerDigits: number;
  32. minimumFractionDigits: number;
  33. maximumFractionDigits: number;
  34. minimumSignificantDigits?: number;
  35. maximumSignificantDigits?: number;
  36. }
  37. interface PluralRules {
  38. resolvedOptions(): ResolvedPluralRulesOptions;
  39. select(n: number): LDMLPluralRule;
  40. }
  41. const PluralRules: {
  42. new (locales?: string | string[], options?: PluralRulesOptions): PluralRules;
  43. (locales?: string | string[], options?: PluralRulesOptions): PluralRules;
  44. supportedLocalesOf(locales: string | string[], options?: { localeMatcher?: "lookup" | "best fit" }): string[];
  45. };
  46. // We can only have one definition for 'type' in TypeScript, and so you can learn where the keys come from here:
  47. type ES2018NumberFormatPartType = "literal" | "nan" | "infinity" | "percent" | "integer" | "group" | "decimal" | "fraction" | "plusSign" | "minusSign" | "percentSign" | "currency" | "code" | "symbol" | "name";
  48. type ES2020NumberFormatPartType = "compact" | "exponentInteger" | "exponentMinusSign" | "exponentSeparator" | "unit" | "unknown";
  49. type NumberFormatPartTypes = ES2018NumberFormatPartType | ES2020NumberFormatPartType;
  50. interface NumberFormatPart {
  51. type: NumberFormatPartTypes;
  52. value: string;
  53. }
  54. interface NumberFormat {
  55. formatToParts(number?: number | bigint): NumberFormatPart[];
  56. }
  57. }