immerjs / immer

Create the next immutable state by mutating the current one
https://immerjs.github.io/immer/
MIT License
27.5k stars 850 forks source link

Make `applyPatches` to accept `readonly Patch[]` #1094

Closed Andarist closed 4 months ago

Andarist commented 6 months ago

My main goal is for applyPatches to accept readonly Patch[] as there is no reason why it shouldn't accept it. If you think that other changes here are too risky (like returning readonly Patch[] from produceWithPatches) then I can revert those bits of this change.

mweststrate commented 6 months ago

Yeah that looks great! I'm not 100% sure about the returned patches indeed, as people might be postprocessing those in a mutable manner. So probably safer to not change right away. (Feel free to set up a separate PR to park for the next major)

mweststrate commented 6 months ago

Looks like some of the tests fail, but overall agree with the idea :)

Andarist commented 6 months ago

@mweststrate I adjusted the PR as requested. There are still some test failures here but they are unrelated to the change - the same ones can be seen main

mweststrate commented 6 months ago

I didn't use GitHub for too long and can't find the rebase button anymore, but master should be fixed now.

Andarist commented 6 months ago

Just rebased this on top of main - it should be ready to go

mweststrate commented 4 months ago

Merging, thanks for the PR and sorry for the delay!

github-actions[bot] commented 4 months ago

:tada: This PR is included in version 10.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: