Skip to content

Replace .at(-1) with array[length-1] for ES2022 compatibility#187

Open
dcroote wants to merge 1 commit intoapi3dao:mainfrom
dcroote:main
Open

Replace .at(-1) with array[length-1] for ES2022 compatibility#187
dcroote wants to merge 1 commit intoapi3dao:mainfrom
dcroote:main

Conversation

@dcroote
Copy link

@dcroote dcroote commented Nov 8, 2025

Closes #186

This was an easy one so gave it to Copilot and it looks good (original PR in my fork here but because I will delete the fork, copied below):

CI failing on TypeScript compilation due to Array.at() method usage, which requires ES2022 lib support.

Changes

  • Replaced attemptTimeoutMs.at(-1) with attemptTimeoutMs[attemptTimeoutMs.length - 1] in src/index.ts:169

Before:

currentAttemptTimeoutMs = attemptTimeoutMs[i] || attemptTimeoutMs.at(-1);

After:

currentAttemptTimeoutMs = attemptTimeoutMs[i] || attemptTimeoutMs[attemptTimeoutMs.length - 1];

Both expressions access the last array element. The latter works with ES5+ without requiring lib configuration changes.

Co-authored-by: dcroote <13989647+dcroote@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsc ci failure

2 participants