Skip to content

Commit 5721f03

Browse files
authored
Merge pull request #10842 from jeffreymorlan/fix-10618
Fix ECMA-402 declarations (issue #10618)
2 parents 65d40f8 + 48a610c commit 5721f03

File tree

3 files changed

+32
-77
lines changed

3 files changed

+32
-77
lines changed

src/lib/es5.d.ts

Lines changed: 20 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3949,12 +3949,9 @@ declare module Intl {
39493949
resolvedOptions(): ResolvedCollatorOptions;
39503950
}
39513951
var Collator: {
3952-
new (locales?: string[], options?: CollatorOptions): Collator;
3953-
new (locale?: string, options?: CollatorOptions): Collator;
3954-
(locales?: string[], options?: CollatorOptions): Collator;
3955-
(locale?: string, options?: CollatorOptions): Collator;
3956-
supportedLocalesOf(locales: string[], options?: CollatorOptions): string[];
3957-
supportedLocalesOf(locale: string, options?: CollatorOptions): string[];
3952+
new (locales?: string | string[], options?: CollatorOptions): Collator;
3953+
(locales?: string | string[], options?: CollatorOptions): Collator;
3954+
supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[];
39583955
}
39593956

39603957
interface NumberFormatOptions {
@@ -3989,12 +3986,9 @@ declare module Intl {
39893986
resolvedOptions(): ResolvedNumberFormatOptions;
39903987
}
39913988
var NumberFormat: {
3992-
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
3993-
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
3994-
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
3995-
(locale?: string, options?: NumberFormatOptions): NumberFormat;
3996-
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
3997-
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
3989+
new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
3990+
(locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
3991+
supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[];
39983992
}
39993993

40003994
interface DateTimeFormatOptions {
@@ -4035,88 +4029,49 @@ declare module Intl {
40354029
resolvedOptions(): ResolvedDateTimeFormatOptions;
40364030
}
40374031
var DateTimeFormat: {
4038-
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
4039-
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
4040-
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
4041-
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
4042-
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
4043-
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
4032+
new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
4033+
(locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
4034+
supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[];
40444035
}
40454036
}
40464037

40474038
interface String {
40484039
/**
4049-
* Determines whether two strings are equivalent in the current locale.
4050-
* @param that String to compare to target string
4051-
* @param locales An 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.
4052-
* @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
4053-
*/
4054-
localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number;
4055-
4056-
/**
4057-
* Determines whether two strings are equivalent in the current locale.
4040+
* Determines whether two strings are equivalent in the current or specified locale.
40584041
* @param that String to compare to target string
4059-
* @param locale Locale tag. 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.
4042+
* @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.
40604043
* @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
40614044
*/
4062-
localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number;
4045+
localeCompare(that: string, locales?: string | string[], options?: Intl.CollatorOptions): number;
40634046
}
40644047

40654048
interface Number {
40664049
/**
40674050
* Converts a number to a string by using the current or specified locale.
4068-
* @param locales An 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.
4051+
* @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.
40694052
* @param options An object that contains one or more properties that specify comparison options.
40704053
*/
4071-
toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string;
4072-
4073-
/**
4074-
* Converts a number to a string by using the current or specified locale.
4075-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
4076-
* @param options An object that contains one or more properties that specify comparison options.
4077-
*/
4078-
toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string;
4054+
toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): string;
40794055
}
40804056

40814057
interface Date {
40824058
/**
40834059
* Converts a date and time to a string by using the current or specified locale.
4084-
* @param locales An 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.
4060+
* @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.
40854061
* @param options An object that contains one or more properties that specify comparison options.
40864062
*/
4087-
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
4088-
/**
4089-
* Converts a date to a string by using the current or specified locale.
4090-
* @param locales An 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.
4091-
* @param options An object that contains one or more properties that specify comparison options.
4092-
*/
4093-
toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
4094-
4095-
/**
4096-
* Converts a time to a string by using the current or specified locale.
4097-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
4098-
* @param options An object that contains one or more properties that specify comparison options.
4099-
*/
4100-
toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string;
4101-
4102-
/**
4103-
* Converts a date and time to a string by using the current or specified locale.
4104-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
4105-
* @param options An object that contains one or more properties that specify comparison options.
4106-
*/
4107-
toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
4108-
4063+
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
41094064
/**
41104065
* Converts a date to a string by using the current or specified locale.
4111-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
4066+
* @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.
41124067
* @param options An object that contains one or more properties that specify comparison options.
41134068
*/
4114-
toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
4069+
toLocaleDateString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
41154070

41164071
/**
41174072
* Converts a time to a string by using the current or specified locale.
4118-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
4073+
* @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.
41194074
* @param options An object that contains one or more properties that specify comparison options.
41204075
*/
4121-
toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
4076+
toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
41224077
}

tests/baselines/reference/library_DatePrototypeProperties.symbols

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ Date.prototype.toTimeString();
3030
>toTimeString : Symbol(Date.toTimeString, Decl(lib.d.ts, --, --))
3131

3232
Date.prototype.toLocaleString();
33-
>Date.prototype.toLocaleString : Symbol(Date.toLocaleString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
33+
>Date.prototype.toLocaleString : Symbol(Date.toLocaleString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
3434
>Date.prototype : Symbol(DateConstructor.prototype, Decl(lib.d.ts, --, --))
3535
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
3636
>prototype : Symbol(DateConstructor.prototype, Decl(lib.d.ts, --, --))
37-
>toLocaleString : Symbol(Date.toLocaleString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
37+
>toLocaleString : Symbol(Date.toLocaleString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
3838

3939
Date.prototype.toLocaleDateString();
40-
>Date.prototype.toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
40+
>Date.prototype.toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
4141
>Date.prototype : Symbol(DateConstructor.prototype, Decl(lib.d.ts, --, --))
4242
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
4343
>prototype : Symbol(DateConstructor.prototype, Decl(lib.d.ts, --, --))
44-
>toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
44+
>toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
4545

4646
Date.prototype.toLocaleTimeString();
47-
>Date.prototype.toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
47+
>Date.prototype.toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
4848
>Date.prototype : Symbol(DateConstructor.prototype, Decl(lib.d.ts, --, --))
4949
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
5050
>prototype : Symbol(DateConstructor.prototype, Decl(lib.d.ts, --, --))
51-
>toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
51+
>toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
5252

5353
Date.prototype.valueOf();
5454
>Date.prototype.valueOf : Symbol(Date.valueOf, Decl(lib.d.ts, --, --))

tests/baselines/reference/library_DatePrototypeProperties.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,27 @@ Date.prototype.toTimeString();
3434

3535
Date.prototype.toLocaleString();
3636
>Date.prototype.toLocaleString() : string
37-
>Date.prototype.toLocaleString : { (): string; (locales?: string[], options?: Intl.DateTimeFormatOptions): string; (locale?: string, options?: Intl.DateTimeFormatOptions): string; }
37+
>Date.prototype.toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; }
3838
>Date.prototype : Date
3939
>Date : DateConstructor
4040
>prototype : Date
41-
>toLocaleString : { (): string; (locales?: string[], options?: Intl.DateTimeFormatOptions): string; (locale?: string, options?: Intl.DateTimeFormatOptions): string; }
41+
>toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; }
4242

4343
Date.prototype.toLocaleDateString();
4444
>Date.prototype.toLocaleDateString() : string
45-
>Date.prototype.toLocaleDateString : { (): string; (locales?: string[], options?: Intl.DateTimeFormatOptions): string; (locale?: string, options?: Intl.DateTimeFormatOptions): string; }
45+
>Date.prototype.toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; }
4646
>Date.prototype : Date
4747
>Date : DateConstructor
4848
>prototype : Date
49-
>toLocaleDateString : { (): string; (locales?: string[], options?: Intl.DateTimeFormatOptions): string; (locale?: string, options?: Intl.DateTimeFormatOptions): string; }
49+
>toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; }
5050

5151
Date.prototype.toLocaleTimeString();
5252
>Date.prototype.toLocaleTimeString() : string
53-
>Date.prototype.toLocaleTimeString : { (): string; (locale?: string[], options?: Intl.DateTimeFormatOptions): string; (locale?: string, options?: Intl.DateTimeFormatOptions): string; }
53+
>Date.prototype.toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; }
5454
>Date.prototype : Date
5555
>Date : DateConstructor
5656
>prototype : Date
57-
>toLocaleTimeString : { (): string; (locale?: string[], options?: Intl.DateTimeFormatOptions): string; (locale?: string, options?: Intl.DateTimeFormatOptions): string; }
57+
>toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; }
5858

5959
Date.prototype.valueOf();
6060
>Date.prototype.valueOf() : number

0 commit comments

Comments
 (0)