Skip to content

fix[bind, bindKey, curry, curryRight]: accept _ as the placeholder like lodash - #2230

Open
h00ns wants to merge 2 commits into
toss:mainfrom
h00ns:fix/compat-toolkit-placeholders
Open

h00ns wants to merge 2 commits into
toss:mainfrom
h00ns:fix/compat-toolkit-placeholders

Conversation

@h00ns

@h00ns h00ns commented Nov 20, 2026

Copy link
Copy Markdown

Summary

In lodash, six functions accept _ as a placeholder: bind, bindKey, curry, curryRight, partial, and partialRight. In es-toolkit/compat, only partial and partialRight do.

import _ from 'es-toolkit/compat';

function greet(this: { user: string }, greeting: string, punctuation: string) {
  return greeting + ' ' + this.user + punctuation;
}

_.bind(greet, { user: 'fred' }, _, '!')('hi');
// lodash: 'hi fred!'
// es-toolkit: ' fred!'

_.bindKey({ user: 'fred', greet }, 'greet', _, '!')('hi');
// lodash: 'hi fred!'
// es-toolkit: ' fred!'

_.curry((a: number, b: number, c: number) => [a, b, c])(1)(_, 3)(2);
// lodash: [1, 2, 3]
// es-toolkit: TypeError: ... is not a function

_.curryRight((a: number, b: number, c: number) => [a, b, c])(3)(1, _)(2);
// lodash: [1, 2, 3]
// es-toolkit: TypeError: ... is not a function

This code compiles without type errors under strict mode with @types/lodash.

Changes

  • Set the placeholder of the other four functions to _ (toolkit) in toolkit.ts, the same way as partial.
  • In curry.ts and curryRight.ts, the placeholder of the returned function was fixed to a Symbol, so it did not match _. Changed it to read curry.placeholder (curryRight.placeholder) instead.
  • Added tests for the four functions in src/compat/toolkit.spec.ts.

…placeholder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
es-toolkit Ready Ready Preview Nov 20, 2026 12:38pm UTC

Request Review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 2ebcda68 Deployed Nov 20, 2026 by vercel[bot]
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