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
This commit is contained in:
jihndai
2022-02-28 18:10:18 -04:00
committed by GitHub
parent 03c11c8f70
commit 1abc47b882
20 changed files with 348 additions and 17 deletions

View File

@@ -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"],

View File

@@ -1,3 +1,5 @@
/// <reference lib="es2020.intl" />
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;

2
src/lib/es2020.d.ts vendored
View File

@@ -1,5 +1,7 @@
/// <reference lib="es2019" />
/// <reference lib="es2020.bigint" />
/// <reference lib="es2020.date" />
/// <reference lib="es2020.number" />
/// <reference lib="es2020.promise" />
/// <reference lib="es2020.sharedmemory" />
/// <reference lib="es2020.string" />

24
src/lib/es2020.date.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
/// <reference lib="es2020.intl" />
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;
}

View File

@@ -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.

10
src/lib/es2020.number.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/// <reference lib="es2020.intl" />
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;
}

View File

@@ -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",

View File

@@ -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

View File

@@ -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))

View File

@@ -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]);

View File

@@ -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))

View File

@@ -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

View File

@@ -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."
]

View File

@@ -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."
]

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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))

View File

@@ -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))

View File

@@ -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]);