From 1abc47b882ddf3b406b1e351e8ddfd60d8a9fd5a Mon Sep 17 00:00:00 2001 From: jihndai <73680880+jihndai@users.noreply.github.com> Date: Mon, 28 Feb 2022 18:10:18 -0400 Subject: [PATCH] Add `Intl.Locale` parameter type to `toLocale[X]String` signatures. (#47811) * add Intl.Locale param type to locales argument in BigInt, Number, and Date methods * update baselines * add test for locales object arguments * fix indentation --- src/compiler/commandLineParser.ts | 2 + src/lib/es2020.bigint.d.ts | 4 +- src/lib/es2020.d.ts | 2 + src/lib/es2020.date.d.ts | 24 ++++ src/lib/es2020.intl.d.ts | 7 ++ src/lib/es2020.number.d.ts | 10 ++ src/lib/libs.json | 2 + tests/baselines/reference/bigintWithLib.types | 16 +-- .../reference/es2020IntlAPIs.symbols | 2 +- .../reference/localesObjectArgument.js | 40 ++++++ .../reference/localesObjectArgument.symbols | 94 ++++++++++++++ .../reference/localesObjectArgument.types | 118 ++++++++++++++++++ .../reactJsxReactResolvedNodeNext.trace.json | 4 + ...eactJsxReactResolvedNodeNextEsm.trace.json | 4 + ...does-not-add-color-when-NO_COLOR-is-set.js | 2 +- ...-when-host-can't-provide-terminal-width.js | 2 +- ...tatus.DiagnosticsPresent_OutputsSkipped.js | 2 +- .../typeGuardConstructorNarrowAny.symbols | 2 +- ...typeGuardConstructorPrimitiveTypes.symbols | 6 +- .../es2020/localesObjectArgument.ts | 22 ++++ 20 files changed, 348 insertions(+), 17 deletions(-) create mode 100644 src/lib/es2020.date.d.ts create mode 100644 src/lib/es2020.number.d.ts create mode 100644 tests/baselines/reference/localesObjectArgument.js create mode 100644 tests/baselines/reference/localesObjectArgument.symbols create mode 100644 tests/baselines/reference/localesObjectArgument.types create mode 100644 tests/cases/conformance/es2020/localesObjectArgument.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f04945739b5..16d52221463 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -68,11 +68,13 @@ namespace ts { ["es2019.string", "lib.es2019.string.d.ts"], ["es2019.symbol", "lib.es2019.symbol.d.ts"], ["es2020.bigint", "lib.es2020.bigint.d.ts"], + ["es2020.date", "lib.es2020.date.d.ts"], ["es2020.promise", "lib.es2020.promise.d.ts"], ["es2020.sharedmemory", "lib.es2020.sharedmemory.d.ts"], ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2020.number", "lib.es2020.number.d.ts"], ["es2021.promise", "lib.es2021.promise.d.ts"], ["es2021.string", "lib.es2021.string.d.ts"], ["es2021.weakref", "lib.es2021.weakref.d.ts"], diff --git a/src/lib/es2020.bigint.d.ts b/src/lib/es2020.bigint.d.ts index 659fa1a4287..50a10c7b33e 100644 --- a/src/lib/es2020.bigint.d.ts +++ b/src/lib/es2020.bigint.d.ts @@ -1,3 +1,5 @@ +/// + interface BigIntToLocaleStringOptions { /** * 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 { toString(radix?: number): string; /** Returns a string representation appropriate to the host environment's current locale. */ - toLocaleString(locales?: string, options?: BigIntToLocaleStringOptions): string; + toLocaleString(locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions): string; /** Returns the primitive value of the specified object. */ valueOf(): bigint; diff --git a/src/lib/es2020.d.ts b/src/lib/es2020.d.ts index f420cd61b1d..8d1fa3bf77d 100644 --- a/src/lib/es2020.d.ts +++ b/src/lib/es2020.d.ts @@ -1,5 +1,7 @@ /// /// +/// +/// /// /// /// diff --git a/src/lib/es2020.date.d.ts b/src/lib/es2020.date.d.ts new file mode 100644 index 00000000000..07af7065f73 --- /dev/null +++ b/src/lib/es2020.date.d.ts @@ -0,0 +1,24 @@ +/// + +interface Date { + /** + * Converts a date and time to a string by using the current or specified locale. + * @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. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date to a string by using the current or specified locale. + * @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. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @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. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; +} \ No newline at end of file diff --git a/src/lib/es2020.intl.d.ts b/src/lib/es2020.intl.d.ts index d340813d0c5..ba57d2e8658 100644 --- a/src/lib/es2020.intl.d.ts +++ b/src/lib/es2020.intl.d.ts @@ -58,6 +58,13 @@ declare namespace Intl { */ type BCP47LanguageTag = string; + /** + * The locale(s) to use + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument). + */ + type LocalesArgument = UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[] | Locale | Locale[] | undefined; + /** * An object with some or all of properties of `options` parameter * of `Intl.RelativeTimeFormat` constructor. diff --git a/src/lib/es2020.number.d.ts b/src/lib/es2020.number.d.ts new file mode 100644 index 00000000000..ba61f3dfd0f --- /dev/null +++ b/src/lib/es2020.number.d.ts @@ -0,0 +1,10 @@ +/// + +interface Number { + /** + * Converts a number to a string by using the current or specified locale. + * @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. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; +} diff --git a/src/lib/libs.json b/src/lib/libs.json index e4434e89ea6..0dbe57f36fa 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -44,11 +44,13 @@ "es2019.string", "es2019.symbol", "es2020.bigint", + "es2020.date", "es2020.promise", "es2020.sharedmemory", "es2020.string", "es2020.symbol.wellknown", "es2020.intl", + "es2020.number", "es2021.string", "es2021.promise", "es2021.weakref", diff --git a/tests/baselines/reference/bigintWithLib.types b/tests/baselines/reference/bigintWithLib.types index 6009dd01cfc..6e4376a0e24 100644 --- a/tests/baselines/reference/bigintWithLib.types +++ b/tests/baselines/reference/bigintWithLib.types @@ -66,26 +66,26 @@ stringVal = bigintVal.toLocaleString(); >stringVal = bigintVal.toLocaleString() : string >stringVal : string >bigintVal.toLocaleString() : string ->bigintVal.toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>bigintVal.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string >bigintVal : bigint ->toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string stringVal = bigintVal.toLocaleString('de-DE'); >stringVal = bigintVal.toLocaleString('de-DE') : string >stringVal : string >bigintVal.toLocaleString('de-DE') : string ->bigintVal.toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>bigintVal.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string >bigintVal : bigint ->toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string >'de-DE' : "de-DE" stringVal = bigintVal.toLocaleString('de-DE', { style: 'currency' }); >stringVal = bigintVal.toLocaleString('de-DE', { style: 'currency' }) : string >stringVal : string >bigintVal.toLocaleString('de-DE', { style: 'currency' }) : string ->bigintVal.toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>bigintVal.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string >bigintVal : bigint ->toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string >'de-DE' : "de-DE" >{ style: 'currency' } : { style: string; } >style : string @@ -95,9 +95,9 @@ stringVal = bigintVal.toLocaleString('de-DE', { style: 'currency', currency: 'EU >stringVal = bigintVal.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }) : string >stringVal : string >bigintVal.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }) : string ->bigintVal.toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>bigintVal.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string >bigintVal : bigint ->toLocaleString : (locales?: string, options?: BigIntToLocaleStringOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string >'de-DE' : "de-DE" >{ style: 'currency', currency: 'EUR' } : { style: string; currency: string; } >style : string diff --git a/tests/baselines/reference/es2020IntlAPIs.symbols b/tests/baselines/reference/es2020IntlAPIs.symbols index 895257b61d2..1738ba245b9 100644 --- a/tests/baselines/reference/es2020IntlAPIs.symbols +++ b/tests/baselines/reference/es2020IntlAPIs.symbols @@ -5,7 +5,7 @@ const count = 26254.39; const date = new Date("2012-05-24"); >date : Symbol(date, Decl(es2020IntlAPIs.ts, 2, 5)) ->Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 1 more) function log(locale: string) { >log : Symbol(log, Decl(es2020IntlAPIs.ts, 2, 36)) diff --git a/tests/baselines/reference/localesObjectArgument.js b/tests/baselines/reference/localesObjectArgument.js new file mode 100644 index 00000000000..092a901e82e --- /dev/null +++ b/tests/baselines/reference/localesObjectArgument.js @@ -0,0 +1,40 @@ +//// [localesObjectArgument.ts] +const enUS = new Intl.Locale("en-US"); +const deDE = new Intl.Locale("de-DE"); +const jaJP = new Intl.Locale("ja-JP"); + +const now = new Date(); +const num = 1000; +const bigint = 123456789123456789n; + +now.toLocaleString(enUS); +now.toLocaleDateString(enUS); +now.toLocaleTimeString(enUS); +now.toLocaleString([deDE, jaJP]); +now.toLocaleDateString([deDE, jaJP]); +now.toLocaleTimeString([deDE, jaJP]); + +num.toLocaleString(enUS); +num.toLocaleString([deDE, jaJP]); + +bigint.toLocaleString(enUS); +bigint.toLocaleString([deDE, jaJP]); + + +//// [localesObjectArgument.js] +const enUS = new Intl.Locale("en-US"); +const deDE = new Intl.Locale("de-DE"); +const jaJP = new Intl.Locale("ja-JP"); +const now = new Date(); +const num = 1000; +const bigint = 123456789123456789n; +now.toLocaleString(enUS); +now.toLocaleDateString(enUS); +now.toLocaleTimeString(enUS); +now.toLocaleString([deDE, jaJP]); +now.toLocaleDateString([deDE, jaJP]); +now.toLocaleTimeString([deDE, jaJP]); +num.toLocaleString(enUS); +num.toLocaleString([deDE, jaJP]); +bigint.toLocaleString(enUS); +bigint.toLocaleString([deDE, jaJP]); diff --git a/tests/baselines/reference/localesObjectArgument.symbols b/tests/baselines/reference/localesObjectArgument.symbols new file mode 100644 index 00000000000..22b05ffd55f --- /dev/null +++ b/tests/baselines/reference/localesObjectArgument.symbols @@ -0,0 +1,94 @@ +=== tests/cases/conformance/es2020/localesObjectArgument.ts === +const enUS = new Intl.Locale("en-US"); +>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 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, --, --)) + +const deDE = new Intl.Locale("de-DE"); +>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 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, --, --)) + +const jaJP = new Intl.Locale("ja-JP"); +>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 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, --, --)) + +const now = new Date(); +>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 1 more) + +const num = 1000; +>num : Symbol(num, Decl(localesObjectArgument.ts, 5, 5)) + +const bigint = 123456789123456789n; +>bigint : Symbol(bigint, Decl(localesObjectArgument.ts, 6, 5)) + +now.toLocaleString(enUS); +>now.toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5)) +>toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5)) + +now.toLocaleDateString(enUS); +>now.toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5)) +>toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5)) + +now.toLocaleTimeString(enUS); +>now.toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5)) +>toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5)) + +now.toLocaleString([deDE, jaJP]); +>now.toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5)) +>toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5)) +>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5)) + +now.toLocaleDateString([deDE, jaJP]); +>now.toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5)) +>toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5)) +>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5)) + +now.toLocaleTimeString([deDE, jaJP]); +>now.toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5)) +>toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --)) +>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5)) +>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5)) + +num.toLocaleString(enUS); +>num.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) +>num : Symbol(num, Decl(localesObjectArgument.ts, 5, 5)) +>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) +>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5)) + +num.toLocaleString([deDE, jaJP]); +>num.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) +>num : Symbol(num, Decl(localesObjectArgument.ts, 5, 5)) +>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) +>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5)) +>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5)) + +bigint.toLocaleString(enUS); +>bigint.toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --)) +>bigint : Symbol(bigint, Decl(localesObjectArgument.ts, 6, 5)) +>toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --)) +>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5)) + +bigint.toLocaleString([deDE, jaJP]); +>bigint.toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --)) +>bigint : Symbol(bigint, Decl(localesObjectArgument.ts, 6, 5)) +>toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --)) +>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5)) +>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5)) + diff --git a/tests/baselines/reference/localesObjectArgument.types b/tests/baselines/reference/localesObjectArgument.types new file mode 100644 index 00000000000..a7a07a6ce6a --- /dev/null +++ b/tests/baselines/reference/localesObjectArgument.types @@ -0,0 +1,118 @@ +=== tests/cases/conformance/es2020/localesObjectArgument.ts === +const enUS = new Intl.Locale("en-US"); +>enUS : Intl.Locale +>new Intl.Locale("en-US") : Intl.Locale +>Intl.Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale +>Intl : typeof Intl +>Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale +>"en-US" : "en-US" + +const deDE = new Intl.Locale("de-DE"); +>deDE : Intl.Locale +>new Intl.Locale("de-DE") : Intl.Locale +>Intl.Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale +>Intl : typeof Intl +>Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale +>"de-DE" : "de-DE" + +const jaJP = new Intl.Locale("ja-JP"); +>jaJP : Intl.Locale +>new Intl.Locale("ja-JP") : Intl.Locale +>Intl.Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale +>Intl : typeof Intl +>Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale +>"ja-JP" : "ja-JP" + +const now = new Date(); +>now : Date +>new Date() : Date +>Date : DateConstructor + +const num = 1000; +>num : 1000 +>1000 : 1000 + +const bigint = 123456789123456789n; +>bigint : 123456789123456789n +>123456789123456789n : 123456789123456789n + +now.toLocaleString(enUS); +>now.toLocaleString(enUS) : string +>now.toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>now : Date +>toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>enUS : Intl.Locale + +now.toLocaleDateString(enUS); +>now.toLocaleDateString(enUS) : string +>now.toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>now : Date +>toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>enUS : Intl.Locale + +now.toLocaleTimeString(enUS); +>now.toLocaleTimeString(enUS) : string +>now.toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>now : Date +>toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>enUS : Intl.Locale + +now.toLocaleString([deDE, jaJP]); +>now.toLocaleString([deDE, jaJP]) : string +>now.toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>now : Date +>toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>[deDE, jaJP] : Intl.Locale[] +>deDE : Intl.Locale +>jaJP : Intl.Locale + +now.toLocaleDateString([deDE, jaJP]); +>now.toLocaleDateString([deDE, jaJP]) : string +>now.toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>now : Date +>toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>[deDE, jaJP] : Intl.Locale[] +>deDE : Intl.Locale +>jaJP : Intl.Locale + +now.toLocaleTimeString([deDE, jaJP]); +>now.toLocaleTimeString([deDE, jaJP]) : string +>now.toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>now : Date +>toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; } +>[deDE, jaJP] : Intl.Locale[] +>deDE : Intl.Locale +>jaJP : Intl.Locale + +num.toLocaleString(enUS); +>num.toLocaleString(enUS) : string +>num.toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } +>num : 1000 +>toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } +>enUS : Intl.Locale + +num.toLocaleString([deDE, jaJP]); +>num.toLocaleString([deDE, jaJP]) : string +>num.toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } +>num : 1000 +>toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } +>[deDE, jaJP] : Intl.Locale[] +>deDE : Intl.Locale +>jaJP : Intl.Locale + +bigint.toLocaleString(enUS); +>bigint.toLocaleString(enUS) : string +>bigint.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string +>bigint : 123456789123456789n +>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string +>enUS : Intl.Locale + +bigint.toLocaleString([deDE, jaJP]); +>bigint.toLocaleString([deDE, jaJP]) : string +>bigint.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string +>bigint : 123456789123456789n +>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string +>[deDE, jaJP] : Intl.Locale[] +>deDE : Intl.Locale +>jaJP : Intl.Locale + diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json b/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json index ed76bdb1760..aff11ff7b34 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNext.trace.json @@ -141,5 +141,9 @@ "File 'package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups." ] \ No newline at end of file diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json index 7d2a5308b9e..783a70f3a41 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json @@ -135,5 +135,9 @@ "File 'package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups." ] \ No newline at end of file diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js index be6c3dace7f..219b3db4208 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js @@ -78,7 +78,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index b4bc812a9da..df15b28f2aa 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -78,7 +78,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index b4bc812a9da..df15b28f2aa 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -78,7 +78,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl default: undefined --allowJs diff --git a/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols b/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols index 980e68c3f1c..05566a91046 100644 --- a/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols +++ b/tests/baselines/reference/typeGuardConstructorNarrowAny.symbols @@ -12,7 +12,7 @@ if (var1.constructor === String) { } if (var1.constructor === Number) { >var1 : Symbol(var1, Decl(typeGuardConstructorNarrowAny.ts, 1, 3)) ->Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) var1; // Number >var1 : Symbol(var1, Decl(typeGuardConstructorNarrowAny.ts, 1, 3)) diff --git a/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols b/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols index 7258c198d18..281c0562042 100644 --- a/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols +++ b/tests/baselines/reference/typeGuardConstructorPrimitiveTypes.symbols @@ -16,7 +16,7 @@ if (var1.constructor === Number) { >var1.constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) >var1 : Symbol(var1, Decl(typeGuardConstructorPrimitiveTypes.ts, 1, 3)) >constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) ->Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) var1; // number >var1 : Symbol(var1, Decl(typeGuardConstructorPrimitiveTypes.ts, 1, 3)) @@ -62,7 +62,7 @@ if (var1.constructor === BigInt) { let var2: String | Number | Boolean | Symbol | BigInt; >var2 : Symbol(var2, Decl(typeGuardConstructorPrimitiveTypes.ts, 22, 3)) >String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 6 more) ->Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) >Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) >BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) @@ -80,7 +80,7 @@ if (var2.constructor === Number) { >var2.constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) >var2 : Symbol(var2, Decl(typeGuardConstructorPrimitiveTypes.ts, 22, 3)) >constructor : Symbol(Object.constructor, Decl(lib.es5.d.ts, --, --)) ->Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --)) var2; // Number >var2 : Symbol(var2, Decl(typeGuardConstructorPrimitiveTypes.ts, 22, 3)) diff --git a/tests/cases/conformance/es2020/localesObjectArgument.ts b/tests/cases/conformance/es2020/localesObjectArgument.ts new file mode 100644 index 00000000000..a89e22ba91d --- /dev/null +++ b/tests/cases/conformance/es2020/localesObjectArgument.ts @@ -0,0 +1,22 @@ +// @target: es2020 + +const enUS = new Intl.Locale("en-US"); +const deDE = new Intl.Locale("de-DE"); +const jaJP = new Intl.Locale("ja-JP"); + +const now = new Date(); +const num = 1000; +const bigint = 123456789123456789n; + +now.toLocaleString(enUS); +now.toLocaleDateString(enUS); +now.toLocaleTimeString(enUS); +now.toLocaleString([deDE, jaJP]); +now.toLocaleDateString([deDE, jaJP]); +now.toLocaleTimeString([deDE, jaJP]); + +num.toLocaleString(enUS); +num.toLocaleString([deDE, jaJP]); + +bigint.toLocaleString(enUS); +bigint.toLocaleString([deDE, jaJP]);