Skip to content

Commit 7a9856b

Browse files
committed
Add .findLast(), .findLastIndex(), and es2023 target
1 parent 44d6b51 commit 7a9856b

File tree

12 files changed

+397
-13
lines changed

12 files changed

+397
-13
lines changed

src/compiler/commandLineParser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace ts {
3434
["es2020", "lib.es2020.d.ts"],
3535
["es2021", "lib.es2021.d.ts"],
3636
["es2022", "lib.es2022.d.ts"],
37+
["es2023", "lib.es2023.d.ts"],
3738
["esnext", "lib.esnext.d.ts"],
3839
// Host only
3940
["dom", "lib.dom.d.ts"],
@@ -85,7 +86,8 @@ namespace ts {
8586
["es2022.object", "lib.es2022.object.d.ts"],
8687
["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
8788
["es2022.string", "lib.es2022.string.d.ts"],
88-
["esnext.array", "lib.es2022.array.d.ts"],
89+
["es2023.array", "lib.es2023.array.d.ts"],
90+
["esnext.array", "lib.es2023.array.d.ts"],
8991
["esnext.symbol", "lib.es2019.symbol.d.ts"],
9092
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
9193
["esnext.intl", "lib.esnext.intl.d.ts"],
@@ -332,6 +334,7 @@ namespace ts {
332334
es2020: ScriptTarget.ES2020,
333335
es2021: ScriptTarget.ES2021,
334336
es2022: ScriptTarget.ES2022,
337+
es2023: ScriptTarget.ES2023,
335338
esnext: ScriptTarget.ESNext,
336339
})),
337340
affectsSourceFile: true,

src/compiler/types.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6523,6 +6523,7 @@ namespace ts {
65236523
ES2020 = 7,
65246524
ES2021 = 8,
65256525
ES2022 = 9,
6526+
ES2023 = 10,
65266527
ESNext = 99,
65276528
JSON = 100,
65286529
Latest = ESNext,
@@ -7003,16 +7004,17 @@ namespace ts {
70037004
ContainsTypeScript = 1 << 0,
70047005
ContainsJsx = 1 << 1,
70057006
ContainsESNext = 1 << 2,
7006-
ContainsES2022 = 1 << 3,
7007-
ContainsES2021 = 1 << 4,
7008-
ContainsES2020 = 1 << 5,
7009-
ContainsES2019 = 1 << 6,
7010-
ContainsES2018 = 1 << 7,
7011-
ContainsES2017 = 1 << 8,
7012-
ContainsES2016 = 1 << 9,
7013-
ContainsES2015 = 1 << 10,
7014-
ContainsGenerator = 1 << 11,
7015-
ContainsDestructuringAssignment = 1 << 12,
7007+
ContainsES2023 = 1 << 3,
7008+
ContainsES2022 = 1 << 4,
7009+
ContainsES2021 = 1 << 5,
7010+
ContainsES2020 = 1 << 6,
7011+
ContainsES2019 = 1 << 7,
7012+
ContainsES2018 = 1 << 8,
7013+
ContainsES2017 = 1 << 9,
7014+
ContainsES2016 = 1 << 10,
7015+
ContainsES2015 = 1 << 11,
7016+
ContainsGenerator = 1 << 12,
7017+
ContainsDestructuringAssignment = 1 << 13,
70167018

70177019
// Markers
70187020
// - Flags used to indicate that a subtree contains a specific transformation.
@@ -7042,6 +7044,7 @@ namespace ts {
70427044
AssertTypeScript = ContainsTypeScript,
70437045
AssertJsx = ContainsJsx,
70447046
AssertESNext = ContainsESNext,
7047+
AssertES2023 = ContainsES2023,
70457048
AssertES2022 = ContainsES2022,
70467049
AssertES2021 = ContainsES2021,
70477050
AssertES2020 = ContainsES2020,

src/compiler/utilities.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,20 @@ namespace ts {
645645
BigUint64Array: ["at"],
646646
ObjectConstructor: ["hasOwn"],
647647
Error: ["cause"]
648+
},
649+
es2023: {
650+
Array: ["findLast", "findLastIndex"],
651+
Int8Array: ["findLast", "findLastIndex"],
652+
Uint8Array: ["findLast", "findLastIndex"],
653+
Uint8ClampedArray: ["findLast", "findLastIndex"],
654+
Int16Array: ["findLast", "findLastIndex"],
655+
Uint16Array: ["findLast", "findLastIndex"],
656+
Int32Array: ["findLast", "findLastIndex"],
657+
Uint32Array: ["findLast", "findLastIndex"],
658+
Float32Array: ["findLast", "findLastIndex"],
659+
Float64Array: ["findLast", "findLastIndex"],
660+
BigInt64Array: ["findLast", "findLastIndex"],
661+
BigUint64Array: ["findLast", "findLastIndex"]
648662
}
649663
};
650664
}

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.ES2023:
18+
return "lib.es2023.full.d.ts";
1719
case ScriptTarget.ES2022:
1820
return "lib.es2022.full.d.ts";
1921
case ScriptTarget.ES2021:

src/lib/es2023.array.d.ts

Lines changed: 324 additions & 0 deletions
Large diffs are not rendered by default.

src/lib/es2023.d.ts

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

src/lib/es2023.full.d.ts

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

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="es2022" />
1+
/// <reference lib="es2023" />
22
/// <reference lib="esnext.intl" />

src/lib/libs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"es2020",
1111
"es2021",
1212
"es2022",
13+
"es2023",
1314
"esnext",
1415
// Host only
1516
"dom.generated",
@@ -61,6 +62,7 @@
6162
"es2022.object",
6263
"es2022.sharedmemory",
6364
"es2022.string",
65+
"es2023.array",
6466
"esnext.intl",
6567
// Default libraries
6668
"es5.full",
@@ -72,6 +74,7 @@
7274
"es2020.full",
7375
"es2021.full",
7476
"es2022.full",
77+
"es2023.full",
7578
"esnext.full"
7679
],
7780
"paths": {

src/server/protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3584,6 +3584,7 @@ namespace ts.server.protocol {
35843584
ES2020 = "ES2020",
35853585
ES2021 = "ES2021",
35863586
ES2022 = "ES2022",
3587+
ES2023 = "ES2023",
35873588
ESNext = "ESNext"
35883589
}
35893590

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ namespace ts {
159159
start: undefined,
160160
length: undefined,
161161
}, {
162-
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.",
162+
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'es2023', 'esnext', 'node16', 'nodenext'.",
163163
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
164164
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
165165

tests/cases/compiler/findLast.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @target: es2023, esnext
2+
3+
[0].findLast(0);
4+
new Int8Array().findLast(0);
5+
new Uint8Array().findLast(0);
6+
new Uint8ClampedArray().findLast(0);
7+
new Int16Array().findLast(0);
8+
new Uint16Array().findLast(0);
9+
new Int32Array().findLast(0);
10+
new Uint32Array().findLast(0);
11+
new Float32Array().findLast(0);
12+
new Float64Array().findLast(0);
13+
new BigInt64Array().findLast(0);
14+
new BigUint64Array().findLast(0);
15+
16+
[0].findLastIndex(0);
17+
new Int8Array().findLastIndex(0);
18+
new Uint8Array().findLastIndex(0);
19+
new Uint8ClampedArray().findLastIndex(0);
20+
new Int16Array().findLastIndex(0);
21+
new Uint16Array().findLastIndex(0);
22+
new Int32Array().findLastIndex(0);
23+
new Uint32Array().findLastIndex(0);
24+
new Float32Array().findLastIndex(0);
25+
new Float64Array().findLastIndex(0);
26+
new BigInt64Array().findLastIndex(0);
27+
new BigUint64Array().findLastIndex(0);

0 commit comments

Comments
 (0)