From d9e044ff0dd86faea3423ebed1eae770959b1559 Mon Sep 17 00:00:00 2001 From: jihndai <73680880+jihndai@users.noreply.github.com> Date: Sat, 26 Mar 2022 17:08:01 -0400 Subject: [PATCH 1/4] update display names types --- src/lib/es2020.intl.d.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/lib/es2020.intl.d.ts b/src/lib/es2020.intl.d.ts index c7d4d725368ea..9a548e9ec4fd7 100644 --- a/src/lib/es2020.intl.d.ts +++ b/src/lib/es2020.intl.d.ts @@ -63,7 +63,7 @@ declare namespace Intl { * * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument). */ - type LocalesArgument = UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[] | Locale | Locale[] | undefined; + type LocalesArgument = UnicodeBCP47LocaleIdentifier | Locale | (UnicodeBCP47LocaleIdentifier | Locale)[] | undefined; /** * An object with some or all of properties of `options` parameter @@ -295,30 +295,32 @@ declare namespace Intl { | "code" | "none"; - type ResolvedDisplayNamesType = + type DisplayNamesType = | "language" | "region" | "script" + | "calendar" + | "dateTimeField" | "currency"; - type DisplayNamesType = - | ResolvedDisplayNamesType - | "calendar" - | "datetimeField"; + type DisplayNamesLanguageDisplay = + | "dialect" + | "standard"; interface DisplayNamesOptions { - localeMatcher: RelativeTimeFormatLocaleMatcher; - style: RelativeTimeFormatStyle; + localeMatcher?: RelativeTimeFormatLocaleMatcher; + style?: RelativeTimeFormatStyle; type: DisplayNamesType; - languageDisplay: "dialect" | "standard"; - fallback: DisplayNamesFallback; + languageDisplay?: DisplayNamesLanguageDisplay; + fallback?: DisplayNamesFallback; } interface ResolvedDisplayNamesOptions { locale: UnicodeBCP47LocaleIdentifier; style: RelativeTimeFormatStyle; - type: ResolvedDisplayNamesType; + type: DisplayNamesType; fallback: DisplayNamesFallback; + languageDisplay?: DisplayNamesLanguageDisplay; } interface DisplayNames { @@ -365,7 +367,7 @@ declare namespace Intl { * * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames). */ - new(locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: Partial): DisplayNames; + new(locales: LocalesArgument, options: DisplayNamesOptions): DisplayNames; /** * Returns an array containing those of the provided locales that are supported in display names without having to fall back to the runtime's default locale. @@ -380,7 +382,7 @@ declare namespace Intl { * * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf). */ - supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: {localeMatcher: RelativeTimeFormatLocaleMatcher}): BCP47LanguageTag[]; + supportedLocalesOf(locales?: LocalesArgument, options?: { localeMatcher?: RelativeTimeFormatLocaleMatcher }): BCP47LanguageTag[]; }; } From 4b31db617945cba9d5f2152afd3a6aeab3ba8c39 Mon Sep 17 00:00:00 2001 From: jihndai <73680880+jihndai@users.noreply.github.com> Date: Sat, 26 Mar 2022 17:19:11 -0400 Subject: [PATCH 2/4] update baselines --- tests/baselines/reference/es2020IntlAPIs.types | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/es2020IntlAPIs.types b/tests/baselines/reference/es2020IntlAPIs.types index fa7ab907a19fc..8cc08f6d8df19 100644 --- a/tests/baselines/reference/es2020IntlAPIs.types +++ b/tests/baselines/reference/es2020IntlAPIs.types @@ -128,9 +128,9 @@ console.log(rtf2.format(2, 'day')); const regionNamesInEnglish = new Intl.DisplayNames(['en'], { type: 'region' }); >regionNamesInEnglish : Intl.DisplayNames >new Intl.DisplayNames(['en'], { type: 'region' }) : Intl.DisplayNames ->Intl.DisplayNames : { new (locales?: string | string[], options?: Partial): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } >Intl : typeof Intl ->DisplayNames : { new (locales?: string | string[], options?: Partial): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } >['en'] : string[] >'en' : "en" >{ type: 'region' } : { type: "region"; } @@ -140,9 +140,9 @@ const regionNamesInEnglish = new Intl.DisplayNames(['en'], { type: 'region' }); const regionNamesInTraditionalChinese = new Intl.DisplayNames(['zh-Hant'], { type: 'region' }); >regionNamesInTraditionalChinese : Intl.DisplayNames >new Intl.DisplayNames(['zh-Hant'], { type: 'region' }) : Intl.DisplayNames ->Intl.DisplayNames : { new (locales?: string | string[], options?: Partial): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } >Intl : typeof Intl ->DisplayNames : { new (locales?: string | string[], options?: Partial): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } >['zh-Hant'] : string[] >'zh-Hant' : "zh-Hant" >{ type: 'region' } : { type: "region"; } @@ -197,11 +197,11 @@ console.log(Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', ')) >Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', ') : string >Intl.DisplayNames.supportedLocalesOf(locales1, options1).join : (separator?: string) => string >Intl.DisplayNames.supportedLocalesOf(locales1, options1) : string[] ->Intl.DisplayNames.supportedLocalesOf : (locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] ->Intl.DisplayNames : { new (locales?: string | string[], options?: Partial): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl.DisplayNames.supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } >Intl : typeof Intl ->DisplayNames : { new (locales?: string | string[], options?: Partial): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } ->supportedLocalesOf : (locales: string | string[], options?: { localeMatcher: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] >locales1 : string[] >options1 : { readonly localeMatcher: "lookup"; } >join : (separator?: string) => string From 7e3bf00d6e0b16c3b615bacb0408ad2ce619d28e Mon Sep 17 00:00:00 2001 From: jihndai <73680880+jihndai@users.noreply.github.com> Date: Sat, 26 Mar 2022 17:21:28 -0400 Subject: [PATCH 3/4] add tests and baselines --- .../reference/es2020IntlAPIs.errors.txt | 29 +++++- tests/baselines/reference/es2020IntlAPIs.js | 21 ++++- .../reference/es2020IntlAPIs.symbols | 67 ++++++++++++++ .../baselines/reference/es2020IntlAPIs.types | 90 +++++++++++++++++++ .../conformance/es2020/es2020IntlAPIs.ts | 12 ++- 5 files changed, 215 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/es2020IntlAPIs.errors.txt b/tests/baselines/reference/es2020IntlAPIs.errors.txt index 0c74f13974c62..4508afc98aaf4 100644 --- a/tests/baselines/reference/es2020IntlAPIs.errors.txt +++ b/tests/baselines/reference/es2020IntlAPIs.errors.txt @@ -1,7 +1,11 @@ tests/cases/conformance/es2020/es2020IntlAPIs.ts(45,1): error TS2554: Expected 1-2 arguments, but got 0. +tests/cases/conformance/es2020/es2020IntlAPIs.ts(48,1): error TS2554: Expected 2 arguments, but got 0. +tests/cases/conformance/es2020/es2020IntlAPIs.ts(49,1): error TS2554: Expected 2 arguments, but got 1. +tests/cases/conformance/es2020/es2020IntlAPIs.ts(50,29): error TS2345: Argument of type '{}' is not assignable to parameter of type 'DisplayNamesOptions'. + Property 'type' is missing in type '{}' but required in type 'DisplayNamesOptions'. -==== tests/cases/conformance/es2020/es2020IntlAPIs.ts (1 errors) ==== +==== tests/cases/conformance/es2020/es2020IntlAPIs.ts (4 errors) ==== // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation const count = 26254.39; const date = new Date("2012-05-24"); @@ -50,4 +54,25 @@ tests/cases/conformance/es2020/es2020IntlAPIs.ts(45,1): error TS2554: Expected 1 ~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 /.ts/lib.es2020.intl.d.ts:311:14: An argument for 'tag' was not provided. - new Intl.Locale(new Intl.Locale('en-US')); \ No newline at end of file + new Intl.Locale(new Intl.Locale('en-US')); + + new Intl.DisplayNames(); // TypeError: invalid_argument + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 2 arguments, but got 0. +!!! related TS6210 /.ts/lib.es2020.intl.d.ts:390:13: An argument for 'locales' was not provided. + new Intl.DisplayNames('en'); // TypeError: invalid_argument + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 2 arguments, but got 1. +!!! related TS6210 /.ts/lib.es2020.intl.d.ts:390:39: An argument for 'options' was not provided. + new Intl.DisplayNames('en', {}); // TypeError: invalid_argument + ~~ +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'DisplayNamesOptions'. +!!! error TS2345: Property 'type' is missing in type '{}' but required in type 'DisplayNamesOptions'. +!!! related TS2728 /.ts/lib.es2020.intl.d.ts:333:9: 'type' is declared here. + + const localesArg = ["es-ES", new Intl.Locale("en-US")]; + console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" + console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] + console.log(Intl.DisplayNames.supportedLocalesOf()); // [] + console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"] + \ No newline at end of file diff --git a/tests/baselines/reference/es2020IntlAPIs.js b/tests/baselines/reference/es2020IntlAPIs.js index d08c2f427cdee..06b7f5577b1d0 100644 --- a/tests/baselines/reference/es2020IntlAPIs.js +++ b/tests/baselines/reference/es2020IntlAPIs.js @@ -44,7 +44,18 @@ const options1 = { localeMatcher: 'lookup' } as const; console.log(Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', ')); new Intl.Locale(); // should error -new Intl.Locale(new Intl.Locale('en-US')); +new Intl.Locale(new Intl.Locale('en-US')); + +new Intl.DisplayNames(); // TypeError: invalid_argument +new Intl.DisplayNames('en'); // TypeError: invalid_argument +new Intl.DisplayNames('en', {}); // TypeError: invalid_argument + +const localesArg = ["es-ES", new Intl.Locale("en-US")]; +console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] +console.log(Intl.DisplayNames.supportedLocalesOf()); // [] +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"] + //// [es2020IntlAPIs.js] // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation @@ -78,3 +89,11 @@ const options1 = { localeMatcher: 'lookup' }; console.log(Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', ')); new Intl.Locale(); // should error new Intl.Locale(new Intl.Locale('en-US')); +new Intl.DisplayNames(); // TypeError: invalid_argument +new Intl.DisplayNames('en'); // TypeError: invalid_argument +new Intl.DisplayNames('en', {}); // TypeError: invalid_argument +const localesArg = ["es-ES", new Intl.Locale("en-US")]; +console.log((new Intl.DisplayNames(localesArg, { type: 'language' })).resolvedOptions().locale); // "es-ES" +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] +console.log(Intl.DisplayNames.supportedLocalesOf()); // [] +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"] diff --git a/tests/baselines/reference/es2020IntlAPIs.symbols b/tests/baselines/reference/es2020IntlAPIs.symbols index 08986c4bf7d44..d4f2a2d41379b 100644 --- a/tests/baselines/reference/es2020IntlAPIs.symbols +++ b/tests/baselines/reference/es2020IntlAPIs.symbols @@ -160,3 +160,70 @@ new Intl.Locale(new Intl.Locale('en-US')); >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +new Intl.DisplayNames(); // TypeError: invalid_argument +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) + +new Intl.DisplayNames('en'); // TypeError: invalid_argument +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) + +new Intl.DisplayNames('en', {}); // TypeError: invalid_argument +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) + +const localesArg = ["es-ES", new Intl.Locale("en-US")]; +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) +>Intl.Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) + +console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>(new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale : Symbol(Intl.ResolvedDisplayNamesOptions.locale, Decl(lib.es2020.intl.d.ts, --, --)) +>(new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions : Symbol(Intl.DisplayNames.resolvedOptions, Decl(lib.es2020.intl.d.ts, --, --)) +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) +>type : Symbol(type, Decl(es2020IntlAPIs.ts, 52, 48)) +>resolvedOptions : Symbol(Intl.DisplayNames.resolvedOptions, Decl(lib.es2020.intl.d.ts, --, --)) +>locale : Symbol(Intl.ResolvedDisplayNamesOptions.locale, Decl(lib.es2020.intl.d.ts, --, --)) + +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>Intl.DisplayNames.supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) + +console.log(Intl.DisplayNames.supportedLocalesOf()); // [] +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>Intl.DisplayNames.supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) + +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"] +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>Intl.DisplayNames.supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) + diff --git a/tests/baselines/reference/es2020IntlAPIs.types b/tests/baselines/reference/es2020IntlAPIs.types index 8cc08f6d8df19..b2f86fac9ad97 100644 --- a/tests/baselines/reference/es2020IntlAPIs.types +++ b/tests/baselines/reference/es2020IntlAPIs.types @@ -224,3 +224,93 @@ new Intl.Locale(new Intl.Locale('en-US')); >Locale : new (tag: string | Intl.Locale, options?: Intl.LocaleOptions) => Intl.Locale >'en-US' : "en-US" +new Intl.DisplayNames(); // TypeError: invalid_argument +>new Intl.DisplayNames() : Intl.DisplayNames +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } + +new Intl.DisplayNames('en'); // TypeError: invalid_argument +>new Intl.DisplayNames('en') : Intl.DisplayNames +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>'en' : "en" + +new Intl.DisplayNames('en', {}); // TypeError: invalid_argument +>new Intl.DisplayNames('en', {}) : Intl.DisplayNames +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>'en' : "en" +>{} : {} + +const localesArg = ["es-ES", new Intl.Locale("en-US")]; +>localesArg : (string | Intl.Locale)[] +>["es-ES", new Intl.Locale("en-US")] : (string | Intl.Locale)[] +>"es-ES" : "es-ES" +>new Intl.Locale("en-US") : Intl.Locale +>Intl.Locale : new (tag: string | Intl.Locale, options?: Intl.LocaleOptions) => Intl.Locale +>Intl : typeof Intl +>Locale : new (tag: string | Intl.Locale, options?: Intl.LocaleOptions) => Intl.Locale +>"en-US" : "en-US" + +console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" +>console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>(new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale : string +>(new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions() : Intl.ResolvedDisplayNamesOptions +>(new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions : () => Intl.ResolvedDisplayNamesOptions +>(new Intl.DisplayNames(localesArg, {type: 'language'})) : Intl.DisplayNames +>new Intl.DisplayNames(localesArg, {type: 'language'}) : Intl.DisplayNames +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>localesArg : (string | Intl.Locale)[] +>{type: 'language'} : { type: "language"; } +>type : "language" +>'language' : "language" +>resolvedOptions : () => Intl.ResolvedDisplayNamesOptions +>locale : string + +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] +>console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>Intl.DisplayNames.supportedLocalesOf(localesArg) : string[] +>Intl.DisplayNames.supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] +>localesArg : (string | Intl.Locale)[] + +console.log(Intl.DisplayNames.supportedLocalesOf()); // [] +>console.log(Intl.DisplayNames.supportedLocalesOf()) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>Intl.DisplayNames.supportedLocalesOf() : string[] +>Intl.DisplayNames.supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] + +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"] +>console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>Intl.DisplayNames.supportedLocalesOf(localesArg, {}) : string[] +>Intl.DisplayNames.supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>supportedLocalesOf : (locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }) => string[] +>localesArg : (string | Intl.Locale)[] +>{} : {} + diff --git a/tests/cases/conformance/es2020/es2020IntlAPIs.ts b/tests/cases/conformance/es2020/es2020IntlAPIs.ts index 70c52a0de3d3f..d9b4df620bee7 100644 --- a/tests/cases/conformance/es2020/es2020IntlAPIs.ts +++ b/tests/cases/conformance/es2020/es2020IntlAPIs.ts @@ -45,4 +45,14 @@ const options1 = { localeMatcher: 'lookup' } as const; console.log(Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', ')); new Intl.Locale(); // should error -new Intl.Locale(new Intl.Locale('en-US')); \ No newline at end of file +new Intl.Locale(new Intl.Locale('en-US')); + +new Intl.DisplayNames(); // TypeError: invalid_argument +new Intl.DisplayNames('en'); // TypeError: invalid_argument +new Intl.DisplayNames('en', {}); // TypeError: invalid_argument + +const localesArg = ["es-ES", new Intl.Locale("en-US")]; +console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] +console.log(Intl.DisplayNames.supportedLocalesOf()); // [] +console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"] From d1c4a020414d9a18315393085b8d6e167248b36c Mon Sep 17 00:00:00 2001 From: jihndai <73680880+jihndai@users.noreply.github.com> Date: Sat, 26 Mar 2022 19:33:03 -0400 Subject: [PATCH 4/4] add another test --- .../reference/es2020IntlAPIs.errors.txt | 1 + tests/baselines/reference/es2020IntlAPIs.js | 2 ++ .../reference/es2020IntlAPIs.symbols | 22 ++++++++++++++----- .../baselines/reference/es2020IntlAPIs.types | 19 ++++++++++++++++ .../conformance/es2020/es2020IntlAPIs.ts | 1 + 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/tests/baselines/reference/es2020IntlAPIs.errors.txt b/tests/baselines/reference/es2020IntlAPIs.errors.txt index 4508afc98aaf4..95b447d43f170 100644 --- a/tests/baselines/reference/es2020IntlAPIs.errors.txt +++ b/tests/baselines/reference/es2020IntlAPIs.errors.txt @@ -69,6 +69,7 @@ tests/cases/conformance/es2020/es2020IntlAPIs.ts(50,29): error TS2345: Argument !!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'DisplayNamesOptions'. !!! error TS2345: Property 'type' is missing in type '{}' but required in type 'DisplayNamesOptions'. !!! related TS2728 /.ts/lib.es2020.intl.d.ts:333:9: 'type' is declared here. + console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English" const localesArg = ["es-ES", new Intl.Locale("en-US")]; console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" diff --git a/tests/baselines/reference/es2020IntlAPIs.js b/tests/baselines/reference/es2020IntlAPIs.js index 06b7f5577b1d0..f440684ea2217 100644 --- a/tests/baselines/reference/es2020IntlAPIs.js +++ b/tests/baselines/reference/es2020IntlAPIs.js @@ -49,6 +49,7 @@ new Intl.Locale(new Intl.Locale('en-US')); new Intl.DisplayNames(); // TypeError: invalid_argument new Intl.DisplayNames('en'); // TypeError: invalid_argument new Intl.DisplayNames('en', {}); // TypeError: invalid_argument +console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English" const localesArg = ["es-ES", new Intl.Locale("en-US")]; console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" @@ -92,6 +93,7 @@ new Intl.Locale(new Intl.Locale('en-US')); new Intl.DisplayNames(); // TypeError: invalid_argument new Intl.DisplayNames('en'); // TypeError: invalid_argument new Intl.DisplayNames('en', {}); // TypeError: invalid_argument +console.log((new Intl.DisplayNames(undefined, { type: 'language' })).of('en-GB')); // "British English" const localesArg = ["es-ES", new Intl.Locale("en-US")]; console.log((new Intl.DisplayNames(localesArg, { type: 'language' })).resolvedOptions().locale); // "es-ES" console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] diff --git a/tests/baselines/reference/es2020IntlAPIs.symbols b/tests/baselines/reference/es2020IntlAPIs.symbols index d4f2a2d41379b..cb66c05131001 100644 --- a/tests/baselines/reference/es2020IntlAPIs.symbols +++ b/tests/baselines/reference/es2020IntlAPIs.symbols @@ -175,8 +175,20 @@ new Intl.DisplayNames('en', {}); // TypeError: invalid_argument >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English" +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>(new Intl.DisplayNames(undefined, {type: 'language'})).of : Symbol(Intl.DisplayNames.of, Decl(lib.es2020.intl.d.ts, --, --)) +>Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) +>undefined : Symbol(undefined) +>type : Symbol(type, Decl(es2020IntlAPIs.ts, 50, 47)) +>of : Symbol(Intl.DisplayNames.of, Decl(lib.es2020.intl.d.ts, --, --)) + const localesArg = ["es-ES", new Intl.Locale("en-US")]; ->localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 52, 5)) >Intl.Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) @@ -190,8 +202,8 @@ console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOpti >Intl.DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) ->localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) ->type : Symbol(type, Decl(es2020IntlAPIs.ts, 52, 48)) +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 52, 5)) +>type : Symbol(type, Decl(es2020IntlAPIs.ts, 53, 48)) >resolvedOptions : Symbol(Intl.DisplayNames.resolvedOptions, Decl(lib.es2020.intl.d.ts, --, --)) >locale : Symbol(Intl.ResolvedDisplayNamesOptions.locale, Decl(lib.es2020.intl.d.ts, --, --)) @@ -204,7 +216,7 @@ console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en- >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) ->localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 52, 5)) console.log(Intl.DisplayNames.supportedLocalesOf()); // [] >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) @@ -225,5 +237,5 @@ console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >DisplayNames : Symbol(Intl.DisplayNames, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --)) >supportedLocalesOf : Symbol(supportedLocalesOf, Decl(lib.es2020.intl.d.ts, --, --)) ->localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 51, 5)) +>localesArg : Symbol(localesArg, Decl(es2020IntlAPIs.ts, 52, 5)) diff --git a/tests/baselines/reference/es2020IntlAPIs.types b/tests/baselines/reference/es2020IntlAPIs.types index b2f86fac9ad97..6014acbd0597b 100644 --- a/tests/baselines/reference/es2020IntlAPIs.types +++ b/tests/baselines/reference/es2020IntlAPIs.types @@ -245,6 +245,25 @@ new Intl.DisplayNames('en', {}); // TypeError: invalid_argument >'en' : "en" >{} : {} +console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English" +>console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>(new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB') : string +>(new Intl.DisplayNames(undefined, {type: 'language'})).of : (code: string) => string +>(new Intl.DisplayNames(undefined, {type: 'language'})) : Intl.DisplayNames +>new Intl.DisplayNames(undefined, {type: 'language'}) : Intl.DisplayNames +>Intl.DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>Intl : typeof Intl +>DisplayNames : { new (locales: Intl.LocalesArgument, options: Intl.DisplayNamesOptions): Intl.DisplayNames; prototype: Intl.DisplayNames; supportedLocalesOf(locales?: Intl.LocalesArgument, options?: { localeMatcher?: Intl.RelativeTimeFormatLocaleMatcher; }): string[]; } +>undefined : undefined +>{type: 'language'} : { type: "language"; } +>type : "language" +>'language' : "language" +>of : (code: string) => string +>'en-GB' : "en-GB" + const localesArg = ["es-ES", new Intl.Locale("en-US")]; >localesArg : (string | Intl.Locale)[] >["es-ES", new Intl.Locale("en-US")] : (string | Intl.Locale)[] diff --git a/tests/cases/conformance/es2020/es2020IntlAPIs.ts b/tests/cases/conformance/es2020/es2020IntlAPIs.ts index d9b4df620bee7..e9687257bfe01 100644 --- a/tests/cases/conformance/es2020/es2020IntlAPIs.ts +++ b/tests/cases/conformance/es2020/es2020IntlAPIs.ts @@ -50,6 +50,7 @@ new Intl.Locale(new Intl.Locale('en-US')); new Intl.DisplayNames(); // TypeError: invalid_argument new Intl.DisplayNames('en'); // TypeError: invalid_argument new Intl.DisplayNames('en', {}); // TypeError: invalid_argument +console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English" const localesArg = ["es-ES", new Intl.Locale("en-US")]; console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES"