Skip to content

Commit 90c5e16

Browse files
committed
add Intl.Locale param type to locales argument in BigInt, Number, and Date methods
1 parent c06849a commit 90c5e16

File tree

7 files changed

+50
-1
lines changed

7 files changed

+50
-1
lines changed

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ namespace ts {
6868
["es2019.string", "lib.es2019.string.d.ts"],
6969
["es2019.symbol", "lib.es2019.symbol.d.ts"],
7070
["es2020.bigint", "lib.es2020.bigint.d.ts"],
71+
["es2020.date", "lib.es2020.date.d.ts"],
7172
["es2020.promise", "lib.es2020.promise.d.ts"],
7273
["es2020.sharedmemory", "lib.es2020.sharedmemory.d.ts"],
7374
["es2020.string", "lib.es2020.string.d.ts"],
7475
["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
7576
["es2020.intl", "lib.es2020.intl.d.ts"],
77+
["es2020.number", "lib.es2020.number.d.ts"],
7678
["es2021.promise", "lib.es2021.promise.d.ts"],
7779
["es2021.string", "lib.es2021.string.d.ts"],
7880
["es2021.weakref", "lib.es2021.weakref.d.ts"],

src/lib/es2020.bigint.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference lib="es2020.intl" />
2+
13
interface BigIntToLocaleStringOptions {
24
/**
35
* The locale matching algorithm to use.The default is "best fit". For information about this option, see the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation Intl page}.
@@ -92,7 +94,7 @@ interface BigInt {
9294
toString(radix?: number): string;
9395

9496
/** Returns a string representation appropriate to the host environment's current locale. */
95-
toLocaleString(locales?: string, options?: BigIntToLocaleStringOptions): string;
97+
toLocaleString(locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions): string;
9698

9799
/** Returns the primitive value of the specified object. */
98100
valueOf(): bigint;

src/lib/es2020.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/// <reference lib="es2019" />
22
/// <reference lib="es2020.bigint" />
3+
/// <reference lib="es2020.date" />
4+
/// <reference lib="es2020.number" />
35
/// <reference lib="es2020.promise" />
46
/// <reference lib="es2020.sharedmemory" />
57
/// <reference lib="es2020.string" />

src/lib/es2020.date.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// <reference lib="es2020.intl" />
2+
3+
interface Date {
4+
/**
5+
* Converts a date and time to a string by using the current or specified locale.
6+
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects 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.
7+
* @param options An object that contains one or more properties that specify comparison options.
8+
*/
9+
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
10+
11+
/**
12+
* Converts a date to a string by using the current or specified locale.
13+
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects 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.
14+
* @param options An object that contains one or more properties that specify comparison options.
15+
*/
16+
toLocaleDateString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
17+
18+
/**
19+
* Converts a time to a string by using the current or specified locale.
20+
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects 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.
21+
* @param options An object that contains one or more properties that specify comparison options.
22+
*/
23+
toLocaleTimeString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
24+
}

src/lib/es2020.intl.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ declare namespace Intl {
5858
*/
5959
type BCP47LanguageTag = string;
6060

61+
/**
62+
* The locale(s) to use
63+
*
64+
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
65+
*/
66+
type LocalesArgument = UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[] | Locale | Locale[] | undefined;
67+
6168
/**
6269
* An object with some or all of properties of `options` parameter
6370
* of `Intl.RelativeTimeFormat` constructor.

src/lib/es2020.number.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference lib="es2020.intl" />
2+
3+
interface Number {
4+
/**
5+
* Converts a number to a string by using the current or specified locale.
6+
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects 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.
7+
* @param options An object that contains one or more properties that specify comparison options.
8+
*/
9+
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string;
10+
}

src/lib/libs.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@
4444
"es2019.string",
4545
"es2019.symbol",
4646
"es2020.bigint",
47+
"es2020.date",
4748
"es2020.promise",
4849
"es2020.sharedmemory",
4950
"es2020.string",
5051
"es2020.symbol.wellknown",
5152
"es2020.intl",
53+
"es2020.number",
5254
"es2021.string",
5355
"es2021.promise",
5456
"es2021.weakref",

0 commit comments

Comments
 (0)