Skip to content

Add 2023 array methods to target features #52242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,20 @@ export function getScriptTargetFeatures(): ScriptTargetFeatures {
BigUint64Array: ["at"],
ObjectConstructor: ["hasOwn"],
Error: ["cause"]
},
es2023: {
Array: ["findLastIndex", "findLast"],
Int8Array: ["findLastIndex", "findLast"],
Uint8Array: ["findLastIndex", "findLast"],
Uint8ClampedArray: ["findLastIndex", "findLast"],
Int16Array: ["findLastIndex", "findLast"],
Uint16Array: ["findLastIndex", "findLast"],
Int32Array: ["findLastIndex", "findLast"],
Uint32Array: ["findLastIndex", "findLast"],
Float32Array: ["findLastIndex", "findLast"],
Float64Array: ["findLastIndex", "findLast"],
BigInt64Array: ["findLastIndex", "findLast"],
BigUint64Array: ["findLastIndex", "findLast"],
}
};
}
Expand Down
109 changes: 109 additions & 0 deletions tests/baselines/reference/findLast(target=es2022).errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.


==== tests/cases/compiler/findLast.ts (26 errors) ====
const itemNumber: number | undefined = [0].findLast((item) => item === 0);
~~~~~~~~
!!! 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.
const itemString: string | undefined = ["string"].findLast((item) => item === "string");
~~~~~~~~
!!! 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.
new Int8Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Uint8Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Uint8ClampedArray().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Int16Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Uint16Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Int32Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Uint32Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Float32Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new Float64Array().findLast((item) => item === 0);
~~~~~~~~
!!! 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.
new BigInt64Array().findLast((item) => item === BigInt(0));
~~~~~~~~
!!! 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.
new BigUint64Array().findLast((item) => item === BigInt(0));
~~~~~~~~
!!! 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.

const indexNumber: number = [0].findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
const indexString: number = ["string"].findLastIndex((item) => item === "string");
~~~~~~~~~~~~~
!!! 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.
new Int8Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Uint8Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Uint8ClampedArray().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Int16Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Uint16Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Int32Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Uint32Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Float32Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new Float64Array().findLastIndex((item) => item === 0);
~~~~~~~~~~~~~
!!! 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.
new BigInt64Array().findLastIndex((item) => item === BigInt(0));
~~~~~~~~~~~~~
!!! 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.
new BigUint64Array().findLastIndex((item) => item === BigInt(0));
~~~~~~~~~~~~~
!!! 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.

57 changes: 57 additions & 0 deletions tests/baselines/reference/findLast(target=es2022).js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//// [findLast.ts]
const itemNumber: number | undefined = [0].findLast((item) => item === 0);
const itemString: string | undefined = ["string"].findLast((item) => item === "string");
new Int8Array().findLast((item) => item === 0);
new Uint8Array().findLast((item) => item === 0);
new Uint8ClampedArray().findLast((item) => item === 0);
new Int16Array().findLast((item) => item === 0);
new Uint16Array().findLast((item) => item === 0);
new Int32Array().findLast((item) => item === 0);
new Uint32Array().findLast((item) => item === 0);
new Float32Array().findLast((item) => item === 0);
new Float64Array().findLast((item) => item === 0);
new BigInt64Array().findLast((item) => item === BigInt(0));
new BigUint64Array().findLast((item) => item === BigInt(0));

const indexNumber: number = [0].findLastIndex((item) => item === 0);
const indexString: number = ["string"].findLastIndex((item) => item === "string");
new Int8Array().findLastIndex((item) => item === 0);
new Uint8Array().findLastIndex((item) => item === 0);
new Uint8ClampedArray().findLastIndex((item) => item === 0);
new Int16Array().findLastIndex((item) => item === 0);
new Uint16Array().findLastIndex((item) => item === 0);
new Int32Array().findLastIndex((item) => item === 0);
new Uint32Array().findLastIndex((item) => item === 0);
new Float32Array().findLastIndex((item) => item === 0);
new Float64Array().findLastIndex((item) => item === 0);
new BigInt64Array().findLastIndex((item) => item === BigInt(0));
new BigUint64Array().findLastIndex((item) => item === BigInt(0));


//// [findLast.js]
const itemNumber = [0].findLast((item) => item === 0);
const itemString = ["string"].findLast((item) => item === "string");
new Int8Array().findLast((item) => item === 0);
new Uint8Array().findLast((item) => item === 0);
new Uint8ClampedArray().findLast((item) => item === 0);
new Int16Array().findLast((item) => item === 0);
new Uint16Array().findLast((item) => item === 0);
new Int32Array().findLast((item) => item === 0);
new Uint32Array().findLast((item) => item === 0);
new Float32Array().findLast((item) => item === 0);
new Float64Array().findLast((item) => item === 0);
new BigInt64Array().findLast((item) => item === BigInt(0));
new BigUint64Array().findLast((item) => item === BigInt(0));
const indexNumber = [0].findLastIndex((item) => item === 0);
const indexString = ["string"].findLastIndex((item) => item === "string");
new Int8Array().findLastIndex((item) => item === 0);
new Uint8Array().findLastIndex((item) => item === 0);
new Uint8ClampedArray().findLastIndex((item) => item === 0);
new Int16Array().findLastIndex((item) => item === 0);
new Uint16Array().findLastIndex((item) => item === 0);
new Int32Array().findLastIndex((item) => item === 0);
new Uint32Array().findLastIndex((item) => item === 0);
new Float32Array().findLastIndex((item) => item === 0);
new Float64Array().findLastIndex((item) => item === 0);
new BigInt64Array().findLastIndex((item) => item === BigInt(0));
new BigUint64Array().findLastIndex((item) => item === BigInt(0));
Loading