Skip to content

Commit a311e25

Browse files
authored
Add 2023 array methods to target features (#52242)
1 parent be488fa commit a311e25

9 files changed

+1210
-1
lines changed

src/compiler/utilities.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,20 @@ export function getScriptTargetFeatures(): ScriptTargetFeatures {
12791279
BigUint64Array: ["at"],
12801280
ObjectConstructor: ["hasOwn"],
12811281
Error: ["cause"]
1282+
},
1283+
es2023: {
1284+
Array: ["findLastIndex", "findLast"],
1285+
Int8Array: ["findLastIndex", "findLast"],
1286+
Uint8Array: ["findLastIndex", "findLast"],
1287+
Uint8ClampedArray: ["findLastIndex", "findLast"],
1288+
Int16Array: ["findLastIndex", "findLast"],
1289+
Uint16Array: ["findLastIndex", "findLast"],
1290+
Int32Array: ["findLastIndex", "findLast"],
1291+
Uint32Array: ["findLastIndex", "findLast"],
1292+
Float32Array: ["findLastIndex", "findLast"],
1293+
Float64Array: ["findLastIndex", "findLast"],
1294+
BigInt64Array: ["findLastIndex", "findLast"],
1295+
BigUint64Array: ["findLastIndex", "findLast"],
12821296
}
12831297
};
12841298
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
tests/cases/compiler/findLast.ts(1,44): error TS2550: Property 'findLast' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
2+
tests/cases/compiler/findLast.ts(2,51): error TS2550: Property 'findLast' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
3+
tests/cases/compiler/findLast.ts(3,17): error TS2550: Property 'findLast' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
4+
tests/cases/compiler/findLast.ts(4,18): error TS2550: Property 'findLast' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
5+
tests/cases/compiler/findLast.ts(5,25): error TS2550: Property 'findLast' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
6+
tests/cases/compiler/findLast.ts(6,18): error TS2550: Property 'findLast' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
7+
tests/cases/compiler/findLast.ts(7,19): error TS2550: Property 'findLast' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
8+
tests/cases/compiler/findLast.ts(8,18): error TS2550: Property 'findLast' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
9+
tests/cases/compiler/findLast.ts(9,19): error TS2550: Property 'findLast' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
10+
tests/cases/compiler/findLast.ts(10,20): error TS2550: Property 'findLast' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
11+
tests/cases/compiler/findLast.ts(11,20): error TS2550: Property 'findLast' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
12+
tests/cases/compiler/findLast.ts(12,21): error TS2550: Property 'findLast' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
13+
tests/cases/compiler/findLast.ts(13,22): error TS2550: Property 'findLast' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
14+
tests/cases/compiler/findLast.ts(15,33): error TS2550: Property 'findLastIndex' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
15+
tests/cases/compiler/findLast.ts(16,40): error TS2550: Property 'findLastIndex' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
16+
tests/cases/compiler/findLast.ts(17,17): error TS2550: Property 'findLastIndex' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
17+
tests/cases/compiler/findLast.ts(18,18): error TS2550: Property 'findLastIndex' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
18+
tests/cases/compiler/findLast.ts(19,25): error TS2550: Property 'findLastIndex' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
19+
tests/cases/compiler/findLast.ts(20,18): error TS2550: Property 'findLastIndex' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
20+
tests/cases/compiler/findLast.ts(21,19): error TS2550: Property 'findLastIndex' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
21+
tests/cases/compiler/findLast.ts(22,18): error TS2550: Property 'findLastIndex' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
22+
tests/cases/compiler/findLast.ts(23,19): error TS2550: Property 'findLastIndex' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
23+
tests/cases/compiler/findLast.ts(24,20): error TS2550: Property 'findLastIndex' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
24+
tests/cases/compiler/findLast.ts(25,20): error TS2550: Property 'findLastIndex' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
25+
tests/cases/compiler/findLast.ts(26,21): error TS2550: Property 'findLastIndex' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
26+
tests/cases/compiler/findLast.ts(27,22): error TS2550: Property 'findLastIndex' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
27+
28+
29+
==== tests/cases/compiler/findLast.ts (26 errors) ====
30+
const itemNumber: number | undefined = [0].findLast((item) => item === 0);
31+
~~~~~~~~
32+
!!! error TS2550: Property 'findLast' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
33+
const itemString: string | undefined = ["string"].findLast((item) => item === "string");
34+
~~~~~~~~
35+
!!! error TS2550: Property 'findLast' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
36+
new Int8Array().findLast((item) => item === 0);
37+
~~~~~~~~
38+
!!! error TS2550: Property 'findLast' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
39+
new Uint8Array().findLast((item) => item === 0);
40+
~~~~~~~~
41+
!!! error TS2550: Property 'findLast' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
42+
new Uint8ClampedArray().findLast((item) => item === 0);
43+
~~~~~~~~
44+
!!! error TS2550: Property 'findLast' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
45+
new Int16Array().findLast((item) => item === 0);
46+
~~~~~~~~
47+
!!! error TS2550: Property 'findLast' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
48+
new Uint16Array().findLast((item) => item === 0);
49+
~~~~~~~~
50+
!!! error TS2550: Property 'findLast' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
51+
new Int32Array().findLast((item) => item === 0);
52+
~~~~~~~~
53+
!!! error TS2550: Property 'findLast' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
54+
new Uint32Array().findLast((item) => item === 0);
55+
~~~~~~~~
56+
!!! error TS2550: Property 'findLast' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
57+
new Float32Array().findLast((item) => item === 0);
58+
~~~~~~~~
59+
!!! error TS2550: Property 'findLast' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
60+
new Float64Array().findLast((item) => item === 0);
61+
~~~~~~~~
62+
!!! error TS2550: Property 'findLast' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
63+
new BigInt64Array().findLast((item) => item === BigInt(0));
64+
~~~~~~~~
65+
!!! error TS2550: Property 'findLast' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
66+
new BigUint64Array().findLast((item) => item === BigInt(0));
67+
~~~~~~~~
68+
!!! error TS2550: Property 'findLast' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
69+
70+
const indexNumber: number = [0].findLastIndex((item) => item === 0);
71+
~~~~~~~~~~~~~
72+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
73+
const indexString: number = ["string"].findLastIndex((item) => item === "string");
74+
~~~~~~~~~~~~~
75+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
76+
new Int8Array().findLastIndex((item) => item === 0);
77+
~~~~~~~~~~~~~
78+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
79+
new Uint8Array().findLastIndex((item) => item === 0);
80+
~~~~~~~~~~~~~
81+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
82+
new Uint8ClampedArray().findLastIndex((item) => item === 0);
83+
~~~~~~~~~~~~~
84+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
85+
new Int16Array().findLastIndex((item) => item === 0);
86+
~~~~~~~~~~~~~
87+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
88+
new Uint16Array().findLastIndex((item) => item === 0);
89+
~~~~~~~~~~~~~
90+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
91+
new Int32Array().findLastIndex((item) => item === 0);
92+
~~~~~~~~~~~~~
93+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
94+
new Uint32Array().findLastIndex((item) => item === 0);
95+
~~~~~~~~~~~~~
96+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
97+
new Float32Array().findLastIndex((item) => item === 0);
98+
~~~~~~~~~~~~~
99+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
100+
new Float64Array().findLastIndex((item) => item === 0);
101+
~~~~~~~~~~~~~
102+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
103+
new BigInt64Array().findLastIndex((item) => item === BigInt(0));
104+
~~~~~~~~~~~~~
105+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
106+
new BigUint64Array().findLastIndex((item) => item === BigInt(0));
107+
~~~~~~~~~~~~~
108+
!!! error TS2550: Property 'findLastIndex' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
109+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//// [findLast.ts]
2+
const itemNumber: number | undefined = [0].findLast((item) => item === 0);
3+
const itemString: string | undefined = ["string"].findLast((item) => item === "string");
4+
new Int8Array().findLast((item) => item === 0);
5+
new Uint8Array().findLast((item) => item === 0);
6+
new Uint8ClampedArray().findLast((item) => item === 0);
7+
new Int16Array().findLast((item) => item === 0);
8+
new Uint16Array().findLast((item) => item === 0);
9+
new Int32Array().findLast((item) => item === 0);
10+
new Uint32Array().findLast((item) => item === 0);
11+
new Float32Array().findLast((item) => item === 0);
12+
new Float64Array().findLast((item) => item === 0);
13+
new BigInt64Array().findLast((item) => item === BigInt(0));
14+
new BigUint64Array().findLast((item) => item === BigInt(0));
15+
16+
const indexNumber: number = [0].findLastIndex((item) => item === 0);
17+
const indexString: number = ["string"].findLastIndex((item) => item === "string");
18+
new Int8Array().findLastIndex((item) => item === 0);
19+
new Uint8Array().findLastIndex((item) => item === 0);
20+
new Uint8ClampedArray().findLastIndex((item) => item === 0);
21+
new Int16Array().findLastIndex((item) => item === 0);
22+
new Uint16Array().findLastIndex((item) => item === 0);
23+
new Int32Array().findLastIndex((item) => item === 0);
24+
new Uint32Array().findLastIndex((item) => item === 0);
25+
new Float32Array().findLastIndex((item) => item === 0);
26+
new Float64Array().findLastIndex((item) => item === 0);
27+
new BigInt64Array().findLastIndex((item) => item === BigInt(0));
28+
new BigUint64Array().findLastIndex((item) => item === BigInt(0));
29+
30+
31+
//// [findLast.js]
32+
const itemNumber = [0].findLast((item) => item === 0);
33+
const itemString = ["string"].findLast((item) => item === "string");
34+
new Int8Array().findLast((item) => item === 0);
35+
new Uint8Array().findLast((item) => item === 0);
36+
new Uint8ClampedArray().findLast((item) => item === 0);
37+
new Int16Array().findLast((item) => item === 0);
38+
new Uint16Array().findLast((item) => item === 0);
39+
new Int32Array().findLast((item) => item === 0);
40+
new Uint32Array().findLast((item) => item === 0);
41+
new Float32Array().findLast((item) => item === 0);
42+
new Float64Array().findLast((item) => item === 0);
43+
new BigInt64Array().findLast((item) => item === BigInt(0));
44+
new BigUint64Array().findLast((item) => item === BigInt(0));
45+
const indexNumber = [0].findLastIndex((item) => item === 0);
46+
const indexString = ["string"].findLastIndex((item) => item === "string");
47+
new Int8Array().findLastIndex((item) => item === 0);
48+
new Uint8Array().findLastIndex((item) => item === 0);
49+
new Uint8ClampedArray().findLastIndex((item) => item === 0);
50+
new Int16Array().findLastIndex((item) => item === 0);
51+
new Uint16Array().findLastIndex((item) => item === 0);
52+
new Int32Array().findLastIndex((item) => item === 0);
53+
new Uint32Array().findLastIndex((item) => item === 0);
54+
new Float32Array().findLastIndex((item) => item === 0);
55+
new Float64Array().findLastIndex((item) => item === 0);
56+
new BigInt64Array().findLastIndex((item) => item === BigInt(0));
57+
new BigUint64Array().findLastIndex((item) => item === BigInt(0));

0 commit comments

Comments
 (0)