Skip to content
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

produceWithPatches doesn't collapse Immutable<Immutable<T>> into Immutable<T> #881

Closed
3 tasks done
adamsmasher opened this issue Dec 9, 2021 · 1 comment
Closed
3 tasks done

Comments

@adamsmasher
Copy link

adamsmasher commented Dec 9, 2021

🐛 Bug Report

I'm using produceWithPatches to update my otherwise immutable state with underlying type T, which I store as a field in a class. I want my class to be generic.

Since produceWithPatches gives me back an Immutable<T>, I also need to make that field of type Immutable<T>, so that
I can assign the result to it.

But this means that when I pass that data into produceWithPatches, it's of type Immutable<T>, which means produceWithPatches gives me back an Immutable<Immutable<T>>, which can't be assigned back to the original data.

Of course, I can cast around this, but ideally casting shouldn't be necessary.

Since this is related to the return type of produceWithPatches, it seems related to #850.

Apologies if I'm missing something here. Thanks!

Link to repro

https://codesandbox.io/s/immutable-immutable-t-rbmvq

Observed behavior

produceWithPatches generates an Immutable<Immutable<T>> when given an Immutable<T>.

Expected behavior

produceWithPatches generates an Immutable<T> when given an Immutable<T>

Environment

  • Immer version: 9.0.7
  • I filed this report against the latest version of Immer
  • Occurs with setUseProxies(true)
  • Occurs with setUseProxies(false) (ES5 only)
@adamsmasher
Copy link
Author

This appears to be fixed now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants