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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immer is modifying baseObject and not throwing exception for nested un-draftable objects. #890

Closed
1 of 3 tasks
keepRunning opened this issue Jan 11, 2022 · 3 comments
Closed
1 of 3 tasks

Comments

@keepRunning
Copy link

馃悰 Bug Report

Based on the documentation, object of type 'class' needs to have [immerable] set to true to be handled.
When [immerable] is not set, it should throw an exception.

However, if the baseObject is plain javascript/(class with immerable set to true) and the nested object is un-draftable(class without immerable), then the baseObject itself is modified and returned without exception.

Link to repro

https://codesandbox.io/s/immer-sandbox-error-forked-rry8q

Observed behavior

BaseObject is modified and returned. No exception is thrown.

Expected behavior

Exception should be thrown.

Environment

We only accept bug reports against the latest Immer version.

  • 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)
@mweststrate
Copy link
Collaborator

That is working as expected, if a class is not marked immerable, it behaves like it would normally do in JavaScript. The fact that it is referred to by a draft is unrelated to that.

@mweststrate
Copy link
Collaborator

See also #686, we could warn more explicitly about this, just not landed it so far for the impact it will have.

@keepRunning
Copy link
Author

Thanks for the clarification.
It will be difficult for us to adopt immer without a exception failure, as we have a highly nested class structure and multiple developers introducing new changes.

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

No branches or pull requests

2 participants