Skip to content

Return undefined only when arr[index] is undefined - #56

Merged
phanect merged 4 commits into
mainfrom
fix-fix-type-check
Dec 2, 2025
Merged

phanect merged 4 commits into
mainfrom
fix-fix-type-check

Conversation

@phanect

@phanect phanect commented Dec 2, 2025

Copy link
Copy Markdown
Owner

Fix a bug caused by #55.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix a bug from issue #55 by adding an undefined check in the getLastElementOf function when withIndex: true. However, the implementation introduces a new bug by incorrectly treating arrays that legitimately contain undefined as their last element.

Key changes:

  • Added conditional logic to return undefined when arr[index] === undefined in the withIndex: true path
  • Bumped package version from 2.0.0 to 2.0.1
  • Updated pnpm packageManager version and added import/order to ESLint rules

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/universal/get-last-element-of.ts Adds undefined check that incorrectly returns undefined for arrays with undefined as last element, creating inconsistent behavior between withIndex true/false paths
package.json Updates version to 2.0.1 and pnpm packageManager to 10.24.0
.vscode/settings.json Adds import/order to ESLint codeActionsOnSave rules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/universal/get-last-element-of.ts Outdated
Comment thread src/universal/get-last-element-of.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/universal/get-last-element-of.ts
Comment thread src/universal/get-last-element-of.ts
@phanect
phanect force-pushed the fix-fix-type-check branch 2 times, most recently from 4024b00 to 56353c3 Compare December 2, 2025 01:34
@phanect
phanect requested a review from Copilot December 2, 2025 01:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@phanect
phanect force-pushed the fix-fix-type-check branch from 56353c3 to d911b71 Compare December 2, 2025 01:40
@phanect
phanect enabled auto-merge (rebase) December 2, 2025 01:40
@phanect
phanect merged commit 9479a9b into main Dec 2, 2025
8 checks passed
@phanect
phanect deleted the fix-fix-type-check branch December 2, 2025 02:27
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.

2 participants