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
Placeholder doesn't work for converted functions unless explicitly recurried #3440
Comments
Hi @daedalus28! Is there a |
Yes, there is. It appears to be a lodash instance, but it is not the same one as what's imported. I'm updating my original post to include the lines I added to test for placeholder: console.log(mutableUnset.placeholder) // <-- Seems to be lodash
console.log(mutableUnset.placeholder == _) // <-- false |
In the one with the explicit curry, |
Can you try using the |
Yup, using |
Nice! This is by design and also why we bolt on the |
I don't think anyone would expect that behavior. Why does simply calling convert create an entirely new instance of lodash? |
In practice, this means every method I convert I'll also have to manually re-curry. If nothing else, converting should optionally allow preserving the placeholder instance. Also, does that mean every time I call convert on a method, I'm creating a whole new instance of lodash in memory? That seems less than ideal from a performance standpoint. |
mutableUnset.placeholder = _ If that works I'll patch |
Yup, reassigning works: it('placeholder for converted functions', () => {
let mutableUnset = _.unset.convert({ immutable: false })
let x = {
a: 1,
b: 1
}
mutableUnset.placeholder = _
console.log(mutableUnset.placeholder == _) // <-- true
let unsetInX = mutableUnset(_, x)
unsetInX('a') // <--- Works :D
console.log(x)
}) |
I would happily do the PR myself but I'm not sure where the code for convert is - it doesn't seem to be in this repo |
Rock 😋! Don't worry, our master branch is a mess with v5 prep, I'll patch in an isolated branch. |
@jdalton not to be annoying, but any idea on an ETA for that fix being published? |
No ETA yet. Thanks for keeping it on my radar though. |
@jdalton is it possible to push a 4.17.5 that just adds this in? |
@jdalton Not to be annoying, but it's been almost 2 months. Any chance of getting the patch released as 4.17.5? |
When we do a backport of webpack's |
@jdalton There's been a couple of fix revision releases, but I haven't seen this in yet. Was it just missing in the changelog, or is this still open? |
Ah @daedalus28! This totally did not get fixed. I missed it 😱 |
@jdalton did that happen? |
Annnnd I missed it. (the three day weekend got me). |
Checking in... any update? |
Patched 2de676f. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When using
convert
on functions from lodash fp, they seem to lose their support for using_
as a placeholder. If I explicitly callcurry
on the result, they regain their placeholder support. Here's a full test case showing a failing test:The text was updated successfully, but these errors were encountered: