typescript 5.4.0-dev.20231129 → 5.4.0-dev.20231201

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,12 +47,13 @@ declare namespace Intl {
47
47
  select(n: number): LDMLPluralRule;
48
48
  }
49
49
 
50
- const PluralRules: {
50
+ interface PluralRulesConstructor {
51
51
  new (locales?: string | string[], options?: PluralRulesOptions): PluralRules;
52
52
  (locales?: string | string[], options?: PluralRulesOptions): PluralRules;
53
-
54
53
  supportedLocalesOf(locales: string | string[], options?: { localeMatcher?: "lookup" | "best fit"; }): string[];
55
- };
54
+ }
55
+
56
+ const PluralRules: PluralRulesConstructor;
56
57
 
57
58
  // We can only have one definition for 'type' in TypeScript, and so you can learn where the keys come from here:
58
59
  type ES2018NumberFormatPartType = "literal" | "nan" | "infinity" | "percent" | "integer" | "group" | "decimal" | "fraction" | "plusSign" | "minusSign" | "percentSign" | "currency" | "code" | "symbol" | "name";
@@ -19,9 +19,11 @@ and limitations under the License.
19
19
  /// <reference lib="es2018.intl" />
20
20
  declare namespace Intl {
21
21
  /**
22
- * [Unicode BCP 47 Locale Identifiers](https://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers) definition.
22
+ * A string that is a valid [Unicode BCP 47 Locale Identifier](https://unicode.org/reports/tr35/#Unicode_locale_identifier).
23
23
  *
24
- * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
24
+ * For example: "fa", "es-MX", "zh-Hant-TW".
25
+ *
26
+ * See [MDN - Intl - locales argument](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
25
27
  */
26
28
  type UnicodeBCP47LocaleIdentifier = string;
27
29
 
@@ -89,16 +91,9 @@ declare namespace Intl {
89
91
  type RelativeTimeFormatStyle = "long" | "short" | "narrow";
90
92
 
91
93
  /**
92
- * [BCP 47 language tag](http://tools.ietf.org/html/rfc5646) definition.
94
+ * The locale or locales to use
93
95
  *
94
- * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
95
- */
96
- type BCP47LanguageTag = string;
97
-
98
- /**
99
- * The locale(s) to use
100
- *
101
- * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
96
+ * See [MDN - Intl - locales argument](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
102
97
  */
103
98
  type LocalesArgument = UnicodeBCP47LocaleIdentifier | Locale | readonly (UnicodeBCP47LocaleIdentifier | Locale)[] | undefined;
104
99
 
@@ -218,7 +213,7 @@ declare namespace Intl {
218
213
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat).
219
214
  */
220
215
  new (
221
- locales?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[],
216
+ locales?: LocalesArgument,
222
217
  options?: RelativeTimeFormatOptions,
223
218
  ): RelativeTimeFormat;
224
219
 
@@ -241,7 +236,7 @@ declare namespace Intl {
241
236
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/supportedLocalesOf).
242
237
  */
243
238
  supportedLocalesOf(
244
- locales?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[],
239
+ locales?: LocalesArgument,
245
240
  options?: RelativeTimeFormatOptions,
246
241
  ): UnicodeBCP47LocaleIdentifier[];
247
242
  };
@@ -312,7 +307,7 @@ declare namespace Intl {
312
307
  /** Attempts to remove information about the locale that would be added by calling `Locale.maximize()`. */
313
308
  minimize(): Locale;
314
309
  /** Returns the locale's full locale identifier string. */
315
- toString(): BCP47LanguageTag;
310
+ toString(): UnicodeBCP47LocaleIdentifier;
316
311
  }
317
312
 
318
313
  /**
@@ -330,7 +325,7 @@ declare namespace Intl {
330
325
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale).
331
326
  */
332
327
  const Locale: {
333
- new (tag: BCP47LanguageTag | Locale, options?: LocaleOptions): Locale;
328
+ new (tag: UnicodeBCP47LocaleIdentifier | Locale, options?: LocaleOptions): Locale;
334
329
  };
335
330
 
336
331
  type DisplayNamesFallback =
@@ -424,6 +419,31 @@ declare namespace Intl {
424
419
  *
425
420
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf).
426
421
  */
427
- supportedLocalesOf(locales?: LocalesArgument, options?: { localeMatcher?: RelativeTimeFormatLocaleMatcher; }): BCP47LanguageTag[];
422
+ supportedLocalesOf(locales?: LocalesArgument, options?: { localeMatcher?: RelativeTimeFormatLocaleMatcher; }): UnicodeBCP47LocaleIdentifier[];
428
423
  };
424
+
425
+ interface CollatorConstructor {
426
+ new (locales?: LocalesArgument, options?: CollatorOptions): Collator;
427
+ (locales?: LocalesArgument, options?: CollatorOptions): Collator;
428
+ supportedLocalesOf(locales: LocalesArgument, options?: CollatorOptions): string[];
429
+ }
430
+
431
+ interface DateTimeFormatConstructor {
432
+ new (locales?: LocalesArgument, options?: DateTimeFormatOptions): DateTimeFormat;
433
+ (locales?: LocalesArgument, options?: DateTimeFormatOptions): DateTimeFormat;
434
+ supportedLocalesOf(locales: LocalesArgument, options?: DateTimeFormatOptions): string[];
435
+ }
436
+
437
+ interface NumberFormatConstructor {
438
+ new (locales?: LocalesArgument, options?: NumberFormatOptions): NumberFormat;
439
+ (locales?: LocalesArgument, options?: NumberFormatOptions): NumberFormat;
440
+ supportedLocalesOf(locales: LocalesArgument, options?: NumberFormatOptions): string[];
441
+ }
442
+
443
+ interface PluralRulesConstructor {
444
+ new (locales?: LocalesArgument, options?: PluralRulesOptions): PluralRules;
445
+ (locales?: LocalesArgument, options?: PluralRulesOptions): PluralRules;
446
+
447
+ supportedLocalesOf(locales: LocalesArgument, options?: { localeMatcher?: "lookup" | "best fit"; }): string[];
448
+ }
429
449
  }
@@ -24,5 +24,19 @@ interface String {
24
24
  * containing the results of that search.
25
25
  * @param regexp A variable name or string literal containing the regular expression pattern and flags.
26
26
  */
27
- matchAll(regexp: RegExp): IterableIterator<RegExpMatchArray>;
27
+ matchAll(regexp: RegExp): IterableIterator<RegExpExecArray>;
28
+
29
+ /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
30
+ toLocaleLowerCase(locales?: Intl.LocalesArgument): string;
31
+
32
+ /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */
33
+ toLocaleUpperCase(locales?: Intl.LocalesArgument): string;
34
+
35
+ /**
36
+ * Determines whether two strings are equivalent in the current or specified locale.
37
+ * @param that String to compare to target string
38
+ * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details.
39
+ * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
40
+ */
41
+ localeCompare(that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): number;
28
42
  }
@@ -143,7 +143,7 @@ declare namespace Intl {
143
143
  *
144
144
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat).
145
145
  */
146
- new (locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: ListFormatOptions): ListFormat;
146
+ new (locales?: LocalesArgument, options?: ListFormatOptions): ListFormat;
147
147
 
148
148
  /**
149
149
  * Returns an array containing those of the provided locales that are
@@ -161,6 +161,6 @@ declare namespace Intl {
161
161
  *
162
162
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf).
163
163
  */
164
- supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<ListFormatOptions, "localeMatcher">): BCP47LanguageTag[];
164
+ supportedLocalesOf(locales: LocalesArgument, options?: Pick<ListFormatOptions, "localeMatcher">): UnicodeBCP47LocaleIdentifier[];
165
165
  };
166
166
  }
@@ -89,7 +89,7 @@ declare namespace Intl {
89
89
  *
90
90
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter).
91
91
  */
92
- new (locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: SegmenterOptions): Segmenter;
92
+ new (locales?: LocalesArgument, options?: SegmenterOptions): Segmenter;
93
93
 
94
94
  /**
95
95
  * Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
@@ -103,7 +103,7 @@ declare namespace Intl {
103
103
  *
104
104
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
105
105
  */
106
- supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<SegmenterOptions, "localeMatcher">): BCP47LanguageTag[];
106
+ supportedLocalesOf(locales: LocalesArgument, options?: Pick<SegmenterOptions, "localeMatcher">): UnicodeBCP47LocaleIdentifier[];
107
107
  };
108
108
 
109
109
  /**
package/lib/lib.es5.d.ts CHANGED
@@ -4418,11 +4418,14 @@ declare namespace Intl {
4418
4418
  compare(x: string, y: string): number;
4419
4419
  resolvedOptions(): ResolvedCollatorOptions;
4420
4420
  }
4421
- var Collator: {
4421
+
4422
+ interface CollatorConstructor {
4422
4423
  new (locales?: string | string[], options?: CollatorOptions): Collator;
4423
4424
  (locales?: string | string[], options?: CollatorOptions): Collator;
4424
4425
  supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[];
4425
- };
4426
+ }
4427
+
4428
+ var Collator: CollatorConstructor;
4426
4429
 
4427
4430
  interface NumberFormatOptions {
4428
4431
  localeMatcher?: string | undefined;
@@ -4454,12 +4457,15 @@ declare namespace Intl {
4454
4457
  format(value: number): string;
4455
4458
  resolvedOptions(): ResolvedNumberFormatOptions;
4456
4459
  }
4457
- var NumberFormat: {
4460
+
4461
+ interface NumberFormatConstructor {
4458
4462
  new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
4459
4463
  (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
4460
4464
  supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[];
4461
4465
  readonly prototype: NumberFormat;
4462
- };
4466
+ }
4467
+
4468
+ var NumberFormat: NumberFormatConstructor;
4463
4469
 
4464
4470
  interface DateTimeFormatOptions {
4465
4471
  localeMatcher?: "best fit" | "lookup" | undefined;
@@ -4498,12 +4504,15 @@ declare namespace Intl {
4498
4504
  format(date?: Date | number): string;
4499
4505
  resolvedOptions(): ResolvedDateTimeFormatOptions;
4500
4506
  }
4501
- var DateTimeFormat: {
4507
+
4508
+ interface DateTimeFormatConstructor {
4502
4509
  new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
4503
4510
  (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
4504
4511
  supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[];
4505
4512
  readonly prototype: DateTimeFormat;
4506
- };
4513
+ }
4514
+
4515
+ var DateTimeFormat: DateTimeFormatConstructor;
4507
4516
  }
4508
4517
 
4509
4518
  interface String {
@@ -20,3 +20,4 @@ and limitations under the License.
20
20
  /// <reference lib="esnext.intl" />
21
21
  /// <reference lib="esnext.decorators" />
22
22
  /// <reference lib="esnext.disposable" />
23
+ /// <reference lib="esnext.promise" />
@@ -0,0 +1,35 @@
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
+
7
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
+ MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+
16
+
17
+ /// <reference no-default-lib="true"/>
18
+
19
+ interface PromiseWithResolvers<T> {
20
+ promise: Promise<T>;
21
+ resolve: (value: T | PromiseLike<T>) => void;
22
+ reject: (reason?: any) => void;
23
+ }
24
+
25
+ interface PromiseConstructor {
26
+ /**
27
+ * Creates a new Promise and returns it in an object, along with its resolve and reject functions.
28
+ * @returns An object with the properties `promise`, `resolve`, and `reject`.
29
+ *
30
+ * ```ts
31
+ * const { promise, resolve, reject } = Promise.withResolvers<T>();
32
+ * ```
33
+ */
34
+ withResolvers<T>(): PromiseWithResolvers<T>;
35
+ }