Skip to content

fix(compat/dropRight): clean up JSDoc by removing duplicate overload and guard param#1789

Open
Antoliny0919 wants to merge 2 commits into
toss:mainfrom
Antoliny0919:update-drop-right-doc
Open

fix(compat/dropRight): clean up JSDoc by removing duplicate overload and guard param#1789
Antoliny0919 wants to merge 2 commits into
toss:mainfrom
Antoliny0919:update-drop-right-doc

Conversation

@Antoliny0919

Copy link
Copy Markdown
Contributor

Summary

  • Renamed the parameters(collection → array n → itemsCount), array seems more appropriate for an ArrayLike value, and itemsCount is chosen for consistency with drop.
  • Removed the JSDoc related to guard.
    I don't think this is something consumers of dropRight need to be aware of when using the function directly.
  • Removed redundant JSDoc comments.

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
es-toolkit Ready Ready Preview, Comment Jul 6, 2026 7:40am

Request Review

@Antoliny0919 Antoliny0919 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I left a few comments on things I was curious about while making the changes, as I wanted to better understand the project 😉

Comment on lines -40 to -43
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
export function dropRight<T>(collection: ArrayLike<T> | null | undefined, itemsCount = 1, guard?: unknown): T[] {
if (!isArrayLike(collection)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I noticed that most implementation signatures also include JSDoc. Is there a reason we document those as well?
When overload signatures are present, some of that information seems redundant to me. Am I missing something? 🤔

* @template T - The type of elements in the array.
* @param collection - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @param [guard] - Enables use as an iteratee for methods like `_.map`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I noticed that many other places also expose the guard parameter in the JSDoc. Is there a reason for documenting guard explicitly?
As described in the docs, I understand that it's there to support cases where the function is passed as an iteratee to methods like map(for Lodash compability...), but I'm wondering if this is something users actually need to know about.
Would it be better to keep this as an internal implementation detail?

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.

1 participant