Skip to content

Commit 940e858

Browse files
author
Dmitry Makhnev
committed
feat(lib/es2020.intl): Add Intl.RelativeTimeFormat (part of microsoft#29129);
1 parent 78748c0 commit 940e858

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed

src/compiler/commandLineParser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace ts {
5353
["es2020.promise", "lib.es2020.promise.d.ts"],
5454
["es2020.string", "lib.es2020.string.d.ts"],
5555
["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
56+
["es2020.intl", "lib.es2020.intl.d.ts"],
5657
["esnext.array", "lib.es2019.array.d.ts"],
5758
["esnext.symbol", "lib.es2019.symbol.d.ts"],
5859
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],

src/lib/es2020.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/// <reference lib="es2020.promise" />
44
/// <reference lib="es2020.string" />
55
/// <reference lib="es2020.symbol.wellknown" />
6+
/// <reference lib="es2020.intl" />

src/lib/es2020.intl.d.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
declare namespace Intl {
2+
type RelativeTimeFormatUnit = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second";
3+
type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit";
4+
type RelativeTimeFormatNumeric = "always" | "auto";
5+
type RelativeTimeFormatStyle = "long" | "short" | "narrow";
6+
7+
interface RelativeTimeFormatOptions {
8+
localeMatcher?: RelativeTimeFormatLocaleMatcher;
9+
numeric?: RelativeTimeFormatNumeric;
10+
style?: RelativeTimeFormatStyle;
11+
}
12+
13+
interface ResolvedRelativeTimeFormatOptions {
14+
locale: string;
15+
style: RelativeTimeFormatStyle;
16+
numeric: RelativeTimeFormatNumeric;
17+
numberingSystem: string;
18+
}
19+
20+
interface RelativeTimeFormatPart {
21+
type: string;
22+
value: string;
23+
unit?: RelativeTimeFormatUnit;
24+
}
25+
26+
interface RelativeTimeFormat {
27+
format(
28+
value: number,
29+
unit: RelativeTimeFormatUnit,
30+
): string;
31+
formatToParts(
32+
value: number,
33+
unit: RelativeTimeFormatUnit,
34+
): RelativeTimeFormatPart[];
35+
resolvedOptions(): ResolvedRelativeTimeFormatOptions;
36+
}
37+
38+
const RelativeTimeFormat: {
39+
new(
40+
locales?: string | string[],
41+
options?: RelativeTimeFormatOptions,
42+
): RelativeTimeFormat;
43+
supportedLocalesOf(
44+
locales: string | string[],
45+
options?: RelativeTimeFormatOptions,
46+
): string[];
47+
}
48+
}

src/lib/libs.json

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"es2020.promise",
4545
"es2020.string",
4646
"es2020.symbol.wellknown",
47+
"es2020.intl",
4748
"esnext.intl",
4849
// Default libraries
4950
"es5.full",

src/testRunner/unittests/config/commandLineParsing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace ts {
8585
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
8686
{
8787
errors: [{
88-
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'.",
88+
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'.",
8989
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
9090
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
9191
file: undefined,

0 commit comments

Comments
 (0)