From 940e85843c8cacda3bedd877dc302ff741e3e710 Mon Sep 17 00:00:00 2001 From: Dmitry Makhnev Date: Wed, 8 Jan 2020 22:37:32 +0300 Subject: [PATCH 1/4] =?UTF-8?q?feat(lib/es2020.intl):=20Add=C2=A0`Intl.Rel?= =?UTF-8?q?ativeTimeFormat`=20(part=20of=20#29129);?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compiler/commandLineParser.ts | 1 + src/lib/es2020.d.ts | 1 + src/lib/es2020.intl.d.ts | 48 +++++++++++++++++++ src/lib/libs.json | 1 + .../unittests/config/commandLineParsing.ts | 2 +- 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/lib/es2020.intl.d.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 300e403b3717f..2046c758d41a2 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -53,6 +53,7 @@ namespace ts { ["es2020.promise", "lib.es2020.promise.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"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], diff --git a/src/lib/es2020.d.ts b/src/lib/es2020.d.ts index 7a83900dcc35a..86b473e6d49d4 100644 --- a/src/lib/es2020.d.ts +++ b/src/lib/es2020.d.ts @@ -3,3 +3,4 @@ /// /// /// +/// diff --git a/src/lib/es2020.intl.d.ts b/src/lib/es2020.intl.d.ts new file mode 100644 index 0000000000000..af03db0876f74 --- /dev/null +++ b/src/lib/es2020.intl.d.ts @@ -0,0 +1,48 @@ +declare namespace Intl { + type RelativeTimeFormatUnit = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second"; + type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit"; + type RelativeTimeFormatNumeric = "always" | "auto"; + type RelativeTimeFormatStyle = "long" | "short" | "narrow"; + + interface RelativeTimeFormatOptions { + localeMatcher?: RelativeTimeFormatLocaleMatcher; + numeric?: RelativeTimeFormatNumeric; + style?: RelativeTimeFormatStyle; + } + + interface ResolvedRelativeTimeFormatOptions { + locale: string; + style: RelativeTimeFormatStyle; + numeric: RelativeTimeFormatNumeric; + numberingSystem: string; + } + + interface RelativeTimeFormatPart { + type: string; + value: string; + unit?: RelativeTimeFormatUnit; + } + + interface RelativeTimeFormat { + format( + value: number, + unit: RelativeTimeFormatUnit, + ): string; + formatToParts( + value: number, + unit: RelativeTimeFormatUnit, + ): RelativeTimeFormatPart[]; + resolvedOptions(): ResolvedRelativeTimeFormatOptions; + } + + const RelativeTimeFormat: { + new( + locales?: string | string[], + options?: RelativeTimeFormatOptions, + ): RelativeTimeFormat; + supportedLocalesOf( + locales: string | string[], + options?: RelativeTimeFormatOptions, + ): string[]; + } +} diff --git a/src/lib/libs.json b/src/lib/libs.json index 286efd6471b59..eb6e9885ce924 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -44,6 +44,7 @@ "es2020.promise", "es2020.string", "es2020.symbol.wellknown", + "es2020.intl", "esnext.intl", // Default libraries "es5.full", diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 47e66bac19735..e3341875b0ffb 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -85,7 +85,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', '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', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', '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', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, From 5b05277fe78b12b2c64534364a88b02a53bdbc4a Mon Sep 17 00:00:00 2001 From: Dmitry Makhnev Date: Wed, 8 Jan 2020 23:26:28 +0300 Subject: [PATCH 2/4] fix(lib/es2020.intl): fix for tests and linters `Intl.RelativeTimeFormat` (part of #29129); --- src/lib/es2020.intl.d.ts | 2 +- src/testRunner/unittests/config/commandLineParsing.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/es2020.intl.d.ts b/src/lib/es2020.intl.d.ts index af03db0876f74..83a1e152f9e60 100644 --- a/src/lib/es2020.intl.d.ts +++ b/src/lib/es2020.intl.d.ts @@ -44,5 +44,5 @@ declare namespace Intl { locales: string | string[], options?: RelativeTimeFormatOptions, ): string[]; - } + }; } diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index e3341875b0ffb..725e3510eee86 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -287,7 +287,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', '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', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', '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', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -306,7 +306,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', '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', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', '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', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, From 316e85f96e906f6b35cf261e99f51f40fd5e6c84 Mon Sep 17 00:00:00 2001 From: Dmitry Makhnev Date: Sun, 10 May 2020 22:53:18 +0300 Subject: [PATCH 3/4] =?UTF-8?q?feat(lib/es2020.intl):=20Add=20TSDoc=20for?= =?UTF-8?q?=C2=A0`Intl.RelativeTimeFormat`=20by=20review=20request=20https?= =?UTF-8?q?://github.com/microsoft/TypeScript/pull/36084#issuecomment-5847?= =?UTF-8?q?69420;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/es2020.intl.d.ts | 226 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 221 insertions(+), 5 deletions(-) diff --git a/src/lib/es2020.intl.d.ts b/src/lib/es2020.intl.d.ts index 83a1e152f9e60..ab43357d933e6 100644 --- a/src/lib/es2020.intl.d.ts +++ b/src/lib/es2020.intl.d.ts @@ -1,22 +1,97 @@ declare namespace Intl { - type RelativeTimeFormatUnit = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second"; + + /** + * [BCP 47 language tag](http://tools.ietf.org/html/rfc5646) definition. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument). + * + * [Wikipedia](https://en.wikipedia.org/wiki/IETF_language_tag). + */ + type BCP47LanguageTag = string; + + /** + * Unit to use in the relative time internationalized message. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format#Parameters). + * + * [Specification](https://tc39.es/ecma402/#sec-singularrelativetimeunit). + */ + type RelativeTimeFormatUnit = + | "year" | "years" + | "quarter" | "quarters" + | "month" | "months" + | "week" | "weeks" + | "day" | "days" + | "hour" | "hours" + | "minute" | "minutes" + | "second" | "seconds" + ; + + /** + * The locale matching algorithm to use. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). + * + * [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat). + */ type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit"; + + /** + * The format of output message. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters). + * + * [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat). + */ type RelativeTimeFormatNumeric = "always" | "auto"; + + /** + * The length of the internationalized message. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters). + * + * [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat). + */ type RelativeTimeFormatStyle = "long" | "short" | "narrow"; + /** + * An object with some or all of properties of `options` parameter + * of `Intl.RelativeTimeFormat` constructor. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters). + * + * [Specification](https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat). + */ interface RelativeTimeFormatOptions { localeMatcher?: RelativeTimeFormatLocaleMatcher; numeric?: RelativeTimeFormatNumeric; style?: RelativeTimeFormatStyle; } + /** + * An object with properties reflecting the locale + * and formatting options computed during initialization + * of the `Intel.RelativeTimeFormat` object + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions#Description). + * + * [Specification](https://tc39.es/ecma402/#table-relativetimeformat-resolvedoptions-properties) + */ interface ResolvedRelativeTimeFormatOptions { - locale: string; + locale: BCP47LanguageTag; style: RelativeTimeFormatStyle; numeric: RelativeTimeFormatNumeric; numberingSystem: string; } + /** + * An object representing the relative time format in parts + * that can be used for custom locale-aware formatting. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts). + * + * [Specification](https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts). + */ interface RelativeTimeFormatPart { type: string; value: string; @@ -24,25 +99,166 @@ declare namespace Intl { } interface RelativeTimeFormat { + /** + * Formats a value and a unit according to the locale + * and formatting options of the given + * [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) + * object. + * + * While this method automatically provides the correct plural forms, + * the grammatical form is otherwise as neutral as possible. + * It is the caller's responsibility to handle cut-off logic + * such as deciding between displaying "in 7 days" or "in 1 week". + * This API does not support relative dates involving compound units. + * e.g "in 5 days and 4 hours". + * + * @param value - Numeric value to use in the internationalized relative time message + * + * @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit) + * to use in the relative time internationalized message. + * Possible values are: `"year"`, `"quarter"`, `"month"`, `"week"`, + * `"day"`, `"hour"`, `"minute"`, `"second"`. + * Plural forms are also permitted. + * + * @throws `RangeError` if `unit` was given something other than `unit` possible values + * + * @returns Internationalized relative time message as string + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format). + * + * [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format). + */ format( value: number, unit: RelativeTimeFormatUnit, ): string; + + /** + * A version of the format method which it returns an array of objects + * which represent "parts" of the object, + * separating the formatted number into its constituent parts + * and separating it from other surrounding text. + * These objects have two properties: + * `type` a NumberFormat formatToParts type, and `value`, + * which is the String which is the component of the output. + * If a "part" came from NumberFormat, + * it will have a unit property which indicates the `unit` being formatted; + * literals which are part of the larger frame will not have this property. + * + * @param value - Numeric value to use in the internationalized relative time message + * + * @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit) + * to use in the relative time internationalized message. + * Possible values are: `"year"`, `"quarter"`, `"month"`, `"week"`, + * `"day"`, `"hour"`, `"minute"`, `"second"`. + * Plural forms are also permitted. + * + * @throws `RangeError` if `unit` was given something other than `unit` possible values + * + * @returns Array of [FormatRelativeTimeToParts](https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts) + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts). + * + * [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.formatToParts). + */ formatToParts( value: number, unit: RelativeTimeFormatUnit, ): RelativeTimeFormatPart[]; + + /** + * Provides access to the locale and options computed during initialization of this `Intl.RelativeTimeFormat` object. + * + * @returns A new object with properties reflecting the locale + * and formatting options computed during initialization + * of the `Intel.RelativeTimeFormat` object. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions). + * + * [Specification](https://tc39.es/ecma402/#sec-intl.relativetimeformat.prototype.resolvedoptions) + */ resolvedOptions(): ResolvedRelativeTimeFormatOptions; } + /** + * The [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) + * object is a constructor for objects that enable language-sensitive relative time formatting. + * + * Part of [Intl object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) + * namespace and the [ECMAScript Internationalization API](https://www.ecma-international.org/publications/standards/Ecma-402.htm). + * + * [Compatibility](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat#Browser_compatibility). + * + * [Polyfills](https://github.com/tc39/proposal-intl-relative-time#polyfills). + */ const RelativeTimeFormat: { + /** + * Constructor creates [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) + * objects + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the locales argument, + * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters) + * with some or all of options of the formatting. + * An object with some or all of the following properties: + * - `localeMatcher` - The locale matching algorithm to use. + * Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`. + * For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). + * - `numeric` - The format of output message. + * Possible values are: `"always"` (default, e.g., `1 day ago`) or `"auto"` (e.g., `yesterday`). + * The `"auto"` value allows to not always have to use numeric values in the output. + * - `style` - The length of the internationalized message. Possible values are: + * `"long"` (default, e.g., in 1 month), + * `"short"` (e.g., in 1 mo.) + * or `"narrow"` (e.g., in 1 mo.). The narrow style could be similar to the short style for some locales. + * + * @returns [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) object. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat). + * + * [Specification](https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor). + */ new( - locales?: string | string[], + locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: RelativeTimeFormatOptions, ): RelativeTimeFormat; + + /** + * Returns an array containing those of the provided locales + * that are supported in date and time formatting + * without having to fall back to the runtime's default locale. + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the locales argument, + * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters) + * with some or all of options of the formatting. + * An object with some or all of the following properties: + * - `localeMatcher` - The locale matching algorithm to use. + * Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`. + * For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). + * - `numeric` - The format of output message. + * Possible values are: `"always"` (default, e.g., `1 day ago`) or `"auto"` (e.g., `yesterday`). + * The `"auto"` value allows to not always have to use numeric values in the output. + * - `style` - The length of the internationalized message. Possible values are: + * `"long"` (default, e.g., in 1 month), + * `"short"` (e.g., in 1 mo.) + * or `"narrow"` (e.g., in 1 mo.). The narrow style could be similar to the short style for some locales. + * + * @returns An array containing those of the provided locales + * that are supported in date and time formatting + * without having to fall back to the runtime's default locale. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/supportedLocalesOf). + * + * [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf). + */ supportedLocalesOf( - locales: string | string[], + locales: BCP47LanguageTag | BCP47LanguageTag[], options?: RelativeTimeFormatOptions, - ): string[]; + ): BCP47LanguageTag[]; }; } From e83d334783b7ccf564cf8186195bc1f19aaf0553 Mon Sep 17 00:00:00 2001 From: Dmitry Makhnev Date: Wed, 13 May 2020 01:38:18 +0300 Subject: [PATCH 4/4] fix(lib/es2020.intl): Fix for tests; --- ...ow-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e9c781c0616d5..e8a58a1673e3a 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 @@ -20,7 +20,7 @@ Options: -t VERSION, --target VERSION Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. -m KIND, --module KIND Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. --lib Specify library files to be included in the compilation. - 'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'es2018' 'es2019' 'es2020' 'esnext' 'dom' 'dom.iterable' 'webworker' 'webworker.importscripts' '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' 'es2018.intl' 'es2018.promise' 'es2018.regexp' 'es2019.array' 'es2019.object' 'es2019.string' 'es2019.symbol' 'es2020.bigint' 'es2020.promise' 'es2020.string' 'es2020.symbol.wellknown' 'esnext.array' 'esnext.symbol' 'esnext.asynciterable' 'esnext.intl' 'esnext.bigint' 'esnext.string' 'esnext.promise' + 'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'es2018' 'es2019' 'es2020' 'esnext' 'dom' 'dom.iterable' 'webworker' 'webworker.importscripts' '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' 'es2018.intl' 'es2018.promise' 'es2018.regexp' 'es2019.array' 'es2019.object' 'es2019.string' 'es2019.symbol' 'es2020.bigint' 'es2020.promise' 'es2020.string' 'es2020.symbol.wellknown' 'es2020.intl' 'esnext.array' 'esnext.symbol' 'esnext.asynciterable' 'esnext.intl' 'esnext.bigint' 'esnext.string' 'esnext.promise' --allowJs Allow javascript files to be compiled. --jsx KIND Specify JSX code generation: 'preserve', 'react-native', or 'react'. -d, --declaration Generates corresponding '.d.ts' file.