Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork866
Throw when accessing non-draftables in strict mode#715
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In strict mode, accessing a non-draftable property will throwOne can use the unsafe function to perform such operationsFixesimmerjs#686
codesandbox-cibot commentedDec 3, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This pull request is automatically built and testable inCodeSandbox. To see build info of the built libraries, clickhere or the icon next to each commit SHA. Latest deployment of this branch, based on commitc60c592:
|
Really awesome! Thanks for doing this :). Looks really promising, just up front a notif that it will probably take me a while to review 😅 |
@mweststrate I'm glad you like it! Take your time to review it |
Uh oh!
There was an error while loading.Please reload this page.
This MR attempts to implement the idea from#686
It adds a
strictMode(falseby default, enabled bysetStrictModeor passingstrictModeinImmerconstructor) that makes it so that accessing non-draftable properties will throw an error, unless the access is made in anunsafecallback.Fixes#686
Example
See the tests for more examples
Limitations
I tried to make it as compliant with existing functionalities as possible. I was not able to make it fully ES5-compliant. There are a few tests that fail when strict mode is enabled in
base.jstests.I do not have enough expertise to fully fix them. Suggestions are welcome