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

Make the error message about Object.freeze more informative (Close #3… #3300

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-rocks-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mobx": patch
---

Make the error message about Object.freeze more informative
4 changes: 2 additions & 2 deletions packages/mobx/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const niceErrors = {
10: "'has()' can only be used on observable objects, arrays and maps",
11: "'get()' can only be used on observable objects, arrays and maps",
12: `Invalid annotation`,
13: `Dynamic observable objects cannot be frozen`,
13: `Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,
14: "Intercept handlers should return nothing or a change object",
15: `Observable arrays cannot be frozen`,
15: `Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,
16: `Modification exception: the internal structure of an observable array was changed.`,
17(index, length) {
return `[mobx.array] Index out of bounds, ${index} is larger than ${length}`
Expand Down