Skip to content

Commit 5b7da72

Browse files
committed
Add target: "es2022"
1 parent feac9eb commit 5b7da72

37 files changed

+842
-37
lines changed

src/compiler/commandLineParser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace ts {
2929
["es2019", "lib.es2019.d.ts"],
3030
["es2020", "lib.es2020.d.ts"],
3131
["es2021", "lib.es2021.d.ts"],
32+
["es2022", "lib.es2022.d.ts"],
3233
["esnext", "lib.esnext.d.ts"],
3334
// Host only
3435
["dom", "lib.dom.d.ts"],
@@ -72,12 +73,14 @@ namespace ts {
7273
["es2021.string", "lib.es2021.string.d.ts"],
7374
["es2021.weakref", "lib.es2021.weakref.d.ts"],
7475
["es2021.intl", "lib.es2021.intl.d.ts"],
75-
["esnext.array", "lib.es2019.array.d.ts"],
76+
["es2022.array", "lib.es2022.array.d.ts"],
77+
["es2022.string", "lib.es2022.string.d.ts"],
78+
["esnext.array", "lib.es2022.array.d.ts"],
7679
["esnext.symbol", "lib.es2019.symbol.d.ts"],
7780
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
7881
["esnext.intl", "lib.esnext.intl.d.ts"],
7982
["esnext.bigint", "lib.es2020.bigint.d.ts"],
80-
["esnext.string", "lib.es2021.string.d.ts"],
83+
["esnext.string", "lib.es2022.string.d.ts"],
8184
["esnext.promise", "lib.es2021.promise.d.ts"],
8285
["esnext.weakref", "lib.es2021.weakref.d.ts"]
8386
];
@@ -308,6 +311,7 @@ namespace ts {
308311
es2019: ScriptTarget.ES2019,
309312
es2020: ScriptTarget.ES2020,
310313
es2021: ScriptTarget.ES2021,
314+
es2022: ScriptTarget.ES2022,
311315
esnext: ScriptTarget.ESNext,
312316
})),
313317
affectsSourceFile: true,

src/compiler/types.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6254,6 +6254,7 @@ namespace ts {
62546254
ES2019 = 6,
62556255
ES2020 = 7,
62566256
ES2021 = 8,
6257+
ES2022 = 9,
62576258
ESNext = 99,
62586259
JSON = 100,
62596260
Latest = ESNext,
@@ -6699,15 +6700,16 @@ namespace ts {
66996700
ContainsTypeScript = 1 << 0,
67006701
ContainsJsx = 1 << 1,
67016702
ContainsESNext = 1 << 2,
6702-
ContainsES2021 = 1 << 3,
6703-
ContainsES2020 = 1 << 4,
6704-
ContainsES2019 = 1 << 5,
6705-
ContainsES2018 = 1 << 6,
6706-
ContainsES2017 = 1 << 7,
6707-
ContainsES2016 = 1 << 8,
6708-
ContainsES2015 = 1 << 9,
6709-
ContainsGenerator = 1 << 10,
6710-
ContainsDestructuringAssignment = 1 << 11,
6703+
ContainsES2022 = 1 << 3,
6704+
ContainsES2021 = 1 << 4,
6705+
ContainsES2020 = 1 << 5,
6706+
ContainsES2019 = 1 << 6,
6707+
ContainsES2018 = 1 << 7,
6708+
ContainsES2017 = 1 << 8,
6709+
ContainsES2016 = 1 << 9,
6710+
ContainsES2015 = 1 << 10,
6711+
ContainsGenerator = 1 << 11,
6712+
ContainsDestructuringAssignment = 1 << 12,
67116713

67126714
// Markers
67136715
// - Flags used to indicate that a subtree contains a specific transformation.
@@ -6736,6 +6738,7 @@ namespace ts {
67366738
AssertTypeScript = ContainsTypeScript,
67376739
AssertJsx = ContainsJsx,
67386740
AssertESNext = ContainsESNext,
6741+
AssertES2022 = ContainsES2022,
67396742
AssertES2021 = ContainsES2021,
67406743
AssertES2020 = ContainsES2020,
67416744
AssertES2019 = ContainsES2019,

src/compiler/utilities.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,21 @@ namespace ts {
627627
PromiseConstructor: ["any"],
628628
String: ["replaceAll"]
629629
},
630+
es2022: {
631+
Array: ["at"],
632+
String: ["at"],
633+
Int8Array: ["at"],
634+
Uint8Array: ["at"],
635+
Uint8ClampedArray: ["at"],
636+
Int16Array: ["at"],
637+
Uint16Array: ["at"],
638+
Int32Array: ["at"],
639+
Uint32Array: ["at"],
640+
Float32Array: ["at"],
641+
Float64Array: ["at"],
642+
BigInt64Array: ["at"],
643+
BigUint64Array: ["at"],
644+
},
630645
esnext: {
631646
NumberFormat: ["formatToParts"]
632647
}

src/compiler/utilitiesPublic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ namespace ts {
1414
switch (getEmitScriptTarget(options)) {
1515
case ScriptTarget.ESNext:
1616
return "lib.esnext.full.d.ts";
17+
case ScriptTarget.ES2022:
18+
return "lib.es2022.full.d.ts";
1719
case ScriptTarget.ES2021:
1820
return "lib.es2021.full.d.ts";
1921
case ScriptTarget.ES2020:

src/lib/es2022.array.d.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
interface Array<T> {
2+
/**
3+
* Returns the item located at the specified index.
4+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
5+
*/
6+
at(index: number): T;
7+
}
8+
9+
interface ReadonlyArray<T> {
10+
/**
11+
* Returns the item located at the specified index.
12+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
13+
*/
14+
at(index: number): T;
15+
}
16+
17+
interface Int8Array {
18+
/**
19+
* Returns the item located at the specified index.
20+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
21+
*/
22+
at(index: number): number;
23+
}
24+
25+
interface Uint8Array {
26+
/**
27+
* Returns the item located at the specified index.
28+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
29+
*/
30+
at(index: number): number;
31+
}
32+
33+
interface Uint8ClampedArray {
34+
/**
35+
* Returns the item located at the specified index.
36+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
37+
*/
38+
at(index: number): number;
39+
}
40+
41+
interface Int16Array {
42+
/**
43+
* Returns the item located at the specified index.
44+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
45+
*/
46+
at(index: number): number;
47+
}
48+
49+
interface Uint16Array {
50+
/**
51+
* Returns the item located at the specified index.
52+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
53+
*/
54+
at(index: number): number;
55+
}
56+
57+
interface Int32Array {
58+
/**
59+
* Returns the item located at the specified index.
60+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
61+
*/
62+
at(index: number): number;
63+
}
64+
65+
interface Uint32Array {
66+
/**
67+
* Returns the item located at the specified index.
68+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
69+
*/
70+
at(index: number): number;
71+
}
72+
73+
interface Float32Array {
74+
/**
75+
* Returns the item located at the specified index.
76+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
77+
*/
78+
at(index: number): number;
79+
}
80+
81+
interface Float64Array {
82+
/**
83+
* Returns the item located at the specified index.
84+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
85+
*/
86+
at(index: number): number;
87+
}
88+
89+
interface BigInt64Array {
90+
/**
91+
* Returns the item located at the specified index.
92+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
93+
*/
94+
at(index: number): number;
95+
}
96+
97+
interface BigUint64Array {
98+
/**
99+
* Returns the item located at the specified index.
100+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
101+
*/
102+
at(index: number): number;
103+
}

src/lib/es2022.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference lib="es2021" />
2+
/// <reference lib="es2022.array" />
3+
/// <reference lib="es2022.string" />

src/lib/es2022.full.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference lib="es2022" />
2+
/// <reference lib="dom" />
3+
/// <reference lib="webworker.importscripts" />
4+
/// <reference lib="scripthost" />
5+
/// <reference lib="dom.iterable" />

src/lib/es2022.string.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface String {
2+
/**
3+
* Returns a new String consisting of the single UTF-16 code unit located at the specified index.
4+
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
5+
*/
6+
at(index: number): string;
7+
}

src/lib/esnext.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/// <reference lib="es2021" />
1+
/// <reference lib="es2022" />
22
/// <reference lib="esnext.intl" />

src/lib/libs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"es2019",
1010
"es2020",
1111
"es2021",
12+
"es2022",
1213
"esnext",
1314
// Host only
1415
"dom.generated",
@@ -52,6 +53,8 @@
5253
"es2021.promise",
5354
"es2021.weakref",
5455
"es2021.intl",
56+
"es2022.array",
57+
"es2022.string",
5558
"esnext.intl",
5659
// Default libraries
5760
"es5.full",
@@ -62,6 +65,7 @@
6265
"es2019.full",
6366
"es2020.full",
6467
"es2021.full",
68+
"es2022.full",
6569
"esnext.full"
6670
],
6771
"paths": {

src/server/protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,6 +3509,7 @@ namespace ts.server.protocol {
35093509
ES2019 = "ES2019",
35103510
ES2020 = "ES2020",
35113511
ES2021 = "ES2021",
3512+
ES2022 = "ES2022",
35123513
ESNext = "ESNext"
35133514
}
35143515

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ namespace ts {
211211
start: undefined,
212212
length: undefined,
213213
}, {
214-
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'esnext'.",
214+
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'.",
215215
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
216216
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
217217

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ declare namespace ts {
30763076
ES2019 = 6,
30773077
ES2020 = 7,
30783078
ES2021 = 8,
3079+
ES2022 = 9,
30793080
ESNext = 99,
30803081
JSON = 100,
30813082
Latest = 99
@@ -9656,6 +9657,7 @@ declare namespace ts.server.protocol {
96569657
ES2019 = "ES2019",
96579658
ES2020 = "ES2020",
96589659
ES2021 = "ES2021",
9660+
ES2022 = "ES2022",
96599661
ESNext = "ESNext"
96609662
}
96619663
enum ClassificationType {

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ declare namespace ts {
30763076
ES2019 = 6,
30773077
ES2020 = 7,
30783078
ES2021 = 8,
3079+
ES2022 = 9,
30793080
ESNext = 99,
30803081
JSON = 100,
30813082
Latest = 99
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [callChainWithSuper.ts]
2+
// GH#34952
3+
class Base { method?() {} }
4+
class Derived extends Base {
5+
method1() { return super.method?.(); }
6+
method2() { return super["method"]?.(); }
7+
}
8+
9+
//// [callChainWithSuper.js]
10+
"use strict";
11+
// GH#34952
12+
class Base {
13+
method() { }
14+
}
15+
class Derived extends Base {
16+
method1() { return super.method?.(); }
17+
method2() { return super["method"]?.(); }
18+
}

tests/baselines/reference/callWithSpread4.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ declare const pli: {
3030

3131
(streams: ReadonlyArray<R | W | RW>): Promise<void>;
3232
>streams : Symbol(streams, Decl(callWithSpread4.ts, 5, 5))
33-
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --))
33+
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more)
3434
>R : Symbol(R, Decl(callWithSpread4.ts, 0, 0))
3535
>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22))
3636
>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22))
@@ -43,7 +43,7 @@ declare const pli: {
4343
>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22))
4444
>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22))
4545
>streams : Symbol(streams, Decl(callWithSpread4.ts, 6, 23))
46-
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
46+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
4747
>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22))
4848
>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22))
4949
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const bar = foo.flatMap(bar => bar as Foo);
1515

1616
interface Foo extends Array<string> {}
1717
>Foo : Symbol(Foo, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 43))
18-
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
18+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
1919

2020
// Repros from comments in #43249
2121

tests/baselines/reference/importExportInternalComments.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ declare module "foo";
44

55
=== tests/cases/compiler/default.ts ===
66
/*1*/ export /*2*/ default /*3*/ Array /*4*/;
7-
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
7+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
88

99
=== tests/cases/compiler/index.ts ===
1010
/*1*/ import /*2*/ D /*3*/, /*4*/ { /*5*/ A /*6*/, /*7*/ B /*8*/ as /*9*/ C /*10*/ } /*11*/ from /*12*/ "foo";

0 commit comments

Comments
 (0)