Preserve error codes in production
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Michel Weststrate · committed by Michel Weststrate · parent 718b7f6 · Browse files · 19 files·+190 added−152 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
19 files+190 added−152 removed
- tests:+90 added−90 removed
- other:+100 added−62 removed
Provenance
- Commit
d005fab- Tree
ad440d0- Author
Michel Weststrate <mweststrate@fb.com>- Committer
Michel Weststrate <mweststrate@fb.com>- Parent
718b7f6
19 files changed+190 added−152 removed
modified:__tests__/__snapshots__/base.js.snap+68 added-68 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`base functionality - es5 (autofreeze) async recipe function works with rejected promises 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;3+exports[`base functionality - es5 (autofreeze) async recipe function works with rejected promises 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;4 5-exports[`base functionality - es5 (autofreeze) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;5+exports[`base functionality - es5 (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;6 7-exports[`base functionality - es5 (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;7+exports[`base functionality - es5 (autofreeze) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;8 9-exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;9+exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;10 11-exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 2`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;11+exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 2`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;12 13-exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 3`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;13+exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 3`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;14 15-exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 4`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;15+exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 4`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;16 17-exports[`base functionality - es5 (autofreeze) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;17+exports[`base functionality - es5 (autofreeze) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;18 19-exports[`base functionality - es5 (autofreeze) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;19+exports[`base functionality - es5 (autofreeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;20 21-exports[`base functionality - es5 (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;21+exports[`base functionality - es5 (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;22 23-exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;23+exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;24 25-exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;25+exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;26 27-exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;27+exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;28 29-exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 2`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;29+exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 2`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;30 31-exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 3`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;31+exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 3`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;32 33-exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 4`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;33+exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 4`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;34 35-exports[`base functionality - es5 (autofreeze)(patch listener) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;35+exports[`base functionality - es5 (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;36 37-exports[`base functionality - es5 (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;37+exports[`base functionality - es5 (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;38 39-exports[`base functionality - es5 (no freeze) async recipe function works with rejected promises 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;39+exports[`base functionality - es5 (no freeze) async recipe function works with rejected promises 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;40 41-exports[`base functionality - es5 (no freeze) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;41+exports[`base functionality - es5 (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;42 43-exports[`base functionality - es5 (no freeze) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;43+exports[`base functionality - es5 (no freeze) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;44 45-exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;45+exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;46 47-exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 2`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;47+exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 2`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;48 49-exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 3`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;49+exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 3`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;50 51-exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 4`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;51+exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 4`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;52 53-exports[`base functionality - es5 (no freeze) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;53+exports[`base functionality - es5 (no freeze) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;54 55-exports[`base functionality - es5 (no freeze) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;55+exports[`base functionality - es5 (no freeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;56 57-exports[`base functionality - es5 (patch listener) async recipe function works with rejected promises 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;57+exports[`base functionality - es5 (patch listener) async recipe function works with rejected promises 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":0,\\"b\\":1}"`;58 59-exports[`base functionality - es5 (patch listener) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;59+exports[`base functionality - es5 (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;60 61-exports[`base functionality - es5 (patch listener) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;61+exports[`base functionality - es5 (patch listener) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;62 63-exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;63+exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;64 65-exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 2`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;65+exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 2`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":1}"`;66 67-exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 3`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;67+exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 3`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;68 69-exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 4`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;69+exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 4`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? [1]"`;70 71-exports[`base functionality - es5 (patch listener) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;71+exports[`base functionality - es5 (patch listener) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;72 73-exports[`base functionality - es5 (patch listener) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;73+exports[`base functionality - es5 (patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;74 75-exports[`base functionality - proxy (autofreeze) array drafts throws when a non-numeric property is added 1`] = `"Invariant failed: Immer only supports setting array indices and the 'length' property"`;75+exports[`base functionality - proxy (autofreeze) array drafts throws when a non-numeric property is added 1`] = `"[Immer] Immer only supports setting array indices and the 'length' property"`;76 77-exports[`base functionality - proxy (autofreeze) array drafts throws when a non-numeric property is deleted 1`] = `"Invariant failed: Immer only supports deleting array indices"`;77+exports[`base functionality - proxy (autofreeze) array drafts throws when a non-numeric property is deleted 1`] = `"[Immer] Immer only supports deleting array indices"`;78 79 exports[`base functionality - proxy (autofreeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;80 81-exports[`base functionality - proxy (autofreeze) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;81+exports[`base functionality - proxy (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;82 83-exports[`base functionality - proxy (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;83+exports[`base functionality - proxy (autofreeze) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;84 85 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;86 87 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 2`] = `"Cannot perform 'set' on a proxy that has been revoked"`;9 unmodified lines97 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;98 99 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;100 101-exports[`base functionality - proxy (autofreeze) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;101+exports[`base functionality - proxy (autofreeze) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;102 103-exports[`base functionality - proxy (autofreeze) throws when Object.defineProperty() is used on drafts 1`] = `"Invariant failed: Object.defineProperty() cannot be used on an Immer draft"`;103+exports[`base functionality - proxy (autofreeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] Object.defineProperty() cannot be used on an Immer draft"`;104 105-exports[`base functionality - proxy (autofreeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"Invariant failed: Object.setPrototypeOf() cannot be used on an Immer draft"`;105+exports[`base functionality - proxy (autofreeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] Object.setPrototypeOf() cannot be used on an Immer draft"`;106 107-exports[`base functionality - proxy (autofreeze) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;107+exports[`base functionality - proxy (autofreeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;108 109-exports[`base functionality - proxy (autofreeze)(patch listener) array drafts throws when a non-numeric property is added 1`] = `"Invariant failed: Immer only supports setting array indices and the 'length' property"`;109+exports[`base functionality - proxy (autofreeze)(patch listener) array drafts throws when a non-numeric property is added 1`] = `"[Immer] Immer only supports setting array indices and the 'length' property"`;110 111-exports[`base functionality - proxy (autofreeze)(patch listener) array drafts throws when a non-numeric property is deleted 1`] = `"Invariant failed: Immer only supports deleting array indices"`;111+exports[`base functionality - proxy (autofreeze)(patch listener) array drafts throws when a non-numeric property is deleted 1`] = `"[Immer] Immer only supports deleting array indices"`;112 113 exports[`base functionality - proxy (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;114 115-exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;115+exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;116 117-exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;117+exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;118 119 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;120 121 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 2`] = `"Cannot perform 'set' on a proxy that has been revoked"`;9 unmodified lines131 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;132 133 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;134 135-exports[`base functionality - proxy (autofreeze)(patch listener) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;135+exports[`base functionality - proxy (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;136 137-exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"Invariant failed: Object.defineProperty() cannot be used on an Immer draft"`;137+exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] Object.defineProperty() cannot be used on an Immer draft"`;138 139-exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"Invariant failed: Object.setPrototypeOf() cannot be used on an Immer draft"`;139+exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] Object.setPrototypeOf() cannot be used on an Immer draft"`;140 141-exports[`base functionality - proxy (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;141+exports[`base functionality - proxy (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;142 143-exports[`base functionality - proxy (no freeze) array drafts throws when a non-numeric property is added 1`] = `"Invariant failed: Immer only supports setting array indices and the 'length' property"`;143+exports[`base functionality - proxy (no freeze) array drafts throws when a non-numeric property is added 1`] = `"[Immer] Immer only supports setting array indices and the 'length' property"`;144 145-exports[`base functionality - proxy (no freeze) array drafts throws when a non-numeric property is deleted 1`] = `"Invariant failed: Immer only supports deleting array indices"`;145+exports[`base functionality - proxy (no freeze) array drafts throws when a non-numeric property is deleted 1`] = `"[Immer] Immer only supports deleting array indices"`;146 147 exports[`base functionality - proxy (no freeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;148 149-exports[`base functionality - proxy (no freeze) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;149+exports[`base functionality - proxy (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;150 151-exports[`base functionality - proxy (no freeze) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;151+exports[`base functionality - proxy (no freeze) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;152 153 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;154 155 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 2`] = `"Cannot perform 'set' on a proxy that has been revoked"`;9 unmodified lines165 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;166 167 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;168 169-exports[`base functionality - proxy (no freeze) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;169+exports[`base functionality - proxy (no freeze) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;170 171-exports[`base functionality - proxy (no freeze) throws when Object.defineProperty() is used on drafts 1`] = `"Invariant failed: Object.defineProperty() cannot be used on an Immer draft"`;171+exports[`base functionality - proxy (no freeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] Object.defineProperty() cannot be used on an Immer draft"`;172 173-exports[`base functionality - proxy (no freeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"Invariant failed: Object.setPrototypeOf() cannot be used on an Immer draft"`;173+exports[`base functionality - proxy (no freeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] Object.setPrototypeOf() cannot be used on an Immer draft"`;174 175-exports[`base functionality - proxy (no freeze) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;175+exports[`base functionality - proxy (no freeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;176 177-exports[`base functionality - proxy (patch listener) array drafts throws when a non-numeric property is added 1`] = `"Invariant failed: Immer only supports setting array indices and the 'length' property"`;177+exports[`base functionality - proxy (patch listener) array drafts throws when a non-numeric property is added 1`] = `"[Immer] Immer only supports setting array indices and the 'length' property"`;178 179-exports[`base functionality - proxy (patch listener) array drafts throws when a non-numeric property is deleted 1`] = `"Invariant failed: Immer only supports deleting array indices"`;179+exports[`base functionality - proxy (patch listener) array drafts throws when a non-numeric property is deleted 1`] = `"[Immer] Immer only supports deleting array indices"`;180 181 exports[`base functionality - proxy (patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;182 183-exports[`base functionality - proxy (patch listener) recipe functions cannot return a modified child draft 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;183+exports[`base functionality - proxy (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;184 185-exports[`base functionality - proxy (patch listener) recipe functions cannot return an object that references itself 1`] = `"Invariant failed: Immer forbids circular references"`;185+exports[`base functionality - proxy (patch listener) recipe functions cannot return an object that references itself 1`] = `"[Immer] Immer forbids circular references"`;186 187 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;188 189 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 2`] = `"Cannot perform 'set' on a proxy that has been revoked"`;9 unmodified lines199 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;200 201 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;202 203-exports[`base functionality - proxy (patch listener) throws on computed properties 1`] = `"Invariant failed: Immer drafts cannot have computed properties"`;203+exports[`base functionality - proxy (patch listener) throws on computed properties 1`] = `"[Immer] Immer drafts cannot have computed properties"`;204 205-exports[`base functionality - proxy (patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"Invariant failed: Object.defineProperty() cannot be used on an Immer draft"`;205+exports[`base functionality - proxy (patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] Object.defineProperty() cannot be used on an Immer draft"`;206 207-exports[`base functionality - proxy (patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"Invariant failed: Object.setPrototypeOf() cannot be used on an Immer draft"`;207+exports[`base functionality - proxy (patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] Object.setPrototypeOf() cannot be used on an Immer draft"`;208 209-exports[`base functionality - proxy (patch listener) throws when the draft is modified and another object is returned 1`] = `"Invariant failed: An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;209+exports[`base functionality - proxy (patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."`;210 211 exports[`complex nesting map / set / object modify deep object 1`] = `212 Object {213 "map": Map {372 unmodified linesmodified:__tests__/__snapshots__/curry.js.snap+8 added-8 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`curry - es5 should check arguments 1`] = `"Invariant failed: The first or second argument to \`produce\` must be a function"`;3+exports[`curry - es5 should check arguments 1`] = `"[Immer] The first or second argument to \`produce\` must be a function"`;4 5-exports[`curry - es5 should check arguments 2`] = `"Invariant failed: The first or second argument to \`produce\` must be a function"`;5+exports[`curry - es5 should check arguments 2`] = `"[Immer] The first or second argument to \`produce\` must be a function"`;6 7-exports[`curry - es5 should check arguments 3`] = `"Invariant failed: The first or second argument to \`produce\` must be a function"`;7+exports[`curry - es5 should check arguments 3`] = `"[Immer] The first or second argument to \`produce\` must be a function"`;8 9-exports[`curry - es5 should check arguments 4`] = `"Invariant failed: The third argument to \`produce\` must be a function or undefined"`;9+exports[`curry - es5 should check arguments 4`] = `"[Immer] The third argument to \`produce\` must be a function or undefined"`;10 11-exports[`curry - proxy should check arguments 1`] = `"Invariant failed: The first or second argument to \`produce\` must be a function"`;11+exports[`curry - proxy should check arguments 1`] = `"[Immer] The first or second argument to \`produce\` must be a function"`;12 13-exports[`curry - proxy should check arguments 2`] = `"Invariant failed: The first or second argument to \`produce\` must be a function"`;13+exports[`curry - proxy should check arguments 2`] = `"[Immer] The first or second argument to \`produce\` must be a function"`;14 15-exports[`curry - proxy should check arguments 3`] = `"Invariant failed: The first or second argument to \`produce\` must be a function"`;15+exports[`curry - proxy should check arguments 3`] = `"[Immer] The first or second argument to \`produce\` must be a function"`;16 17-exports[`curry - proxy should check arguments 4`] = `"Invariant failed: The third argument to \`produce\` must be a function or undefined"`;17+exports[`curry - proxy should check arguments 4`] = `"[Immer] The third argument to \`produce\` must be a function or undefined"`;modified:__tests__/__snapshots__/manual.js.snap+10 added-10 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`manual - es5 cannot modify after finish 1`] = `"Invariant failed: Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":2}"`;3+exports[`manual - es5 cannot modify after finish 1`] = `"[Immer] Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? {\\"a\\":2}"`;4 5-exports[`manual - es5 should check arguments 1`] = `"Invariant failed: First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;5+exports[`manual - es5 should check arguments 1`] = `"[Immer] First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;6 7-exports[`manual - es5 should check arguments 2`] = `"Invariant failed: First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;7+exports[`manual - es5 should check arguments 2`] = `"[Immer] First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;8 9-exports[`manual - es5 should check arguments 3`] = `"Invariant failed: First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;9+exports[`manual - es5 should check arguments 3`] = `"[Immer] First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;10 11-exports[`manual - es5 should not finish drafts from produce 1`] = `"Invariant failed: First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;11+exports[`manual - es5 should not finish drafts from produce 1`] = `"[Immer] First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;12 13-exports[`manual - es5 should not finish twice 1`] = `"Invariant failed: The given draft is already finalized"`;13+exports[`manual - es5 should not finish twice 1`] = `"[Immer] The given draft is already finalized"`;14 15 exports[`manual - es5 should support patches drafts 1`] = `16 Array [17 Array [33 unmodified lines51 `;52 53 exports[`manual - proxy cannot modify after finish 1`] = `"Cannot perform 'set' on a proxy that has been revoked"`;54 55-exports[`manual - proxy should check arguments 1`] = `"Invariant failed: First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;55+exports[`manual - proxy should check arguments 1`] = `"[Immer] First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;56 57-exports[`manual - proxy should check arguments 2`] = `"Invariant failed: First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;57+exports[`manual - proxy should check arguments 2`] = `"[Immer] First argument to \`createDraft\` must be a plain object, an array, or an immerable object"`;58 59-exports[`manual - proxy should check arguments 3`] = `"Invariant failed: First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;59+exports[`manual - proxy should check arguments 3`] = `"[Immer] First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;60 61-exports[`manual - proxy should not finish drafts from produce 1`] = `"Invariant failed: First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;61+exports[`manual - proxy should not finish drafts from produce 1`] = `"[Immer] First argument to \`finishDraft\` must be a draft returned by \`createDraft\`"`;62 63 exports[`manual - proxy should not finish twice 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;64 65 exports[`manual - proxy should support patches drafts 1`] = `36 unmodified linesmodified:__tests__/__snapshots__/patch.js.snap+3 added-3 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"Invariant failed: Unsupported patch operation: copy"`;3+exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"[Immer] Unsupported patch operation: copy"`;4 5-exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"Invariant failed: Cannot apply patch, path doesn't resolve: a/b"`;5+exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] Cannot apply patch, path doesn't resolve: a/b"`;6 7-exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"Invariant failed: Cannot apply patch, path doesn't resolve: a/b/c"`;7+exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"[Immer] Cannot apply patch, path doesn't resolve: a/b/c"`;modified:__tests__/readme.js+1 added-1 removed
231 unmodified lines232 // The old one was never modified233 expect(usersById_v1.size).toBe(0)234 // And trying to change a Map outside a producers is going to: NO!235 expect(() => usersById_v3.clear()).toThrowErrorMatchingInlineSnapshot(236- `"Invariant failed: This object has been frozen and should not be mutated"`236+ `"[Immer] This object has been frozen and should not be mutated"`237 )238 })modified:src/plugins/es5.ts+6 added-2 removed
9 unmodified lines10 isDraftable,11 shallowCopy,12 latest,13 DRAFT_STATE,14- assertUnrevoked,14 is,15 loadPlugin,16 ImmerScope,17 createProxy,18 ProxyTypeES5Array,19 ProxyTypeES5Object,21- AnyObject20+ AnyObject,21+ die22 } from "../internal"23 24 type ES5State = ES5ArrayState | ES5ObjectState25 274 unmodified lines300 const desc = Object.getOwnPropertyDescriptor(base, prop)301 return desc && desc.enumerable ? true : false302 }303 304+ function assertUnrevoked(state: any /*ES5State | MapState | SetState*/) {305+ if (state.revoked_) die(3, JSON.stringify(latest(state)))306+ }307+308 loadPlugin("es5", {309 createES5Proxy_,310 markChangedES5_,311 willFinalizeES5_2 unmodified linesmodified:src/plugins/mapset.ts+6 added-6 removed
6 unmodified lines7 SetState,8 DRAFT_STATE,9 ImmerScope,10 latest,11- assertUnrevoked,11 iteratorSymbol,12 isDraftable,13 createProxy,14 loadPlugin,15 markChanged,16 ProxyTypeMap,18- ProxyTypeSet17+ ProxyTypeSet,18+ die19 } from "../internal"20-import invariant from "tiny-invariant"20 21 export function enableMapSet() {22 /* istanbul ignore next */23 var extendStatics = function(d: any, b: any): any {20 unmodified lines44 ((__.prototype = b.prototype), new __())45 }46 47 const DraftMap = (function(_super) {49- invariant(_super, "Map is not polyfilled")48 __extends(DraftMap, _super)49 // Create class manually, cause #50250 function DraftMap(this: any, target: AnyMap, parent?: ImmerState): any {51 this[DRAFT_STATE] = {146 unmodified lines198 }199 }200 201 const DraftSet = (function(_super) {204- invariant(_super, "Set is not polyfilled")205-202 __extends(DraftSet, _super)203 // Create class manually, cause #502204 function DraftSet(this: any, target: AnySet, parent?: ImmerState) {205 this[DRAFT_STATE] = {125 unmodified lines331 })332 }333 }334 335+ function assertUnrevoked(state: any /*ES5State | MapState | SetState*/) {336+ if (state.revoked_) die(3, JSON.stringify(latest(state)))337+ }338+339 loadPlugin("mapset", {proxyMap_, proxySet_})340 }modified:src/plugins/patches.ts+5 added-5 removed
22 unmodified lines23 ProxyTypeProxyArray,24 ProxyTypeSet,25 ArchtypeMap,26 ArchtypeSet,27- ArchtypeArray27+ ArchtypeArray,28+ die29 } from "../internal"29-import invariant from "tiny-invariant"30 31 export function enablePatches() {32 function generatePatches_(33 state: ImmerState,163 unmodified lines197 198 let base: any = draft199 for (let i = 0; i < path.length - 1; i++) {200 base = get(base, path[i])201- invariant(typeof base === "object","Cannot apply patch, path doesn't resolve: " + path.join("/")) // prettier-ignore201+ if (typeof base !== "object") die(15, path.join("/"))202 }203 204 const type = getArchtype(base)205 const value = deepClonePatchValue(patch.value) // used to clone patch to ensure original patch is not modified, see #4114 unmodified lines210 case ArchtypeMap:211 return base.set(key, value)212 /* istanbul ignore next */213 case ArchtypeSet:214- invariant(false, 'Sets cannot have "replace" patches.')214+ die(16)215 default:216 // if value is an object, then it's assigned by reference217 // in the following add or remove ops, the value field inside the patch will also be modifyed218 // so we use value from the cloned patch22 unmodified lines241 default:242 return delete base[key]243 }244 default:245- invariant(false, "Unsupported patch operation: " + op)245+ die(17, op)246 }247 })248 249 return draft21 unmodified linesmodified:src/common.ts+4 added-13 removed
11 unmodified lines12 hasMap,13 ArchtypeObject,14 ArchtypeArray,15 ArchtypeMap,16- ArchtypeSet16+ ArchtypeSet,17+ die18 } from "./internal"18-import invariant from "tiny-invariant"19 20 /** Returns true if the given value is an Immer draft */21 /*#__PURE__*/22 export function isDraft(value: any): boolean {138 unmodified lines161 }162 const desc = Object.getOwnPropertyDescriptor(base, key)!163 let {value} = desc164 if (desc.get) {165- invariant(invokeGetters, "Immer drafts cannot have computed properties")165+ if (!invokeGetters) die(1)166 value = desc.get.call(base)167 }168 if (desc.enumerable) {169 clone[key] = value17 unmodified lines187 if (deep) each(obj, (_, value) => freeze(value, true))188 }189 190 function dontMutateFrozenCollections() {191- invariant(false, "This object has been frozen and should not be mutated")191+ die(2)192 }193-194-// TODO: move to ES5 / Map195-export function assertUnrevoked(state: any /*ES5State | MapState | SetState*/) {196- invariant(197- !state.revoked_,198- "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " +199- JSON.stringify(latest(state))200- )201-}added:src/errors.ts+48 added
1+declare const __DEV__: boolean2+3+const errors = {4+ 0: "Illegal state",5+ 1: "Immer drafts cannot have computed properties",6+ 2: "This object has been frozen and should not be mutated",7+ 3(data: any) {8+ return (9+ "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " +10+ data11+ )12+ },13+ 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",14+ 5: "Immer forbids circular references",15+ 6: "The first or second argument to `produce` must be a function",16+ 7: "The third argument to `produce` must be a function or undefined",17+ 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object",18+ 9: "First argument to `finishDraft` must be a draft returned by `createDraft`",19+ 10: "The given draft is already finalized",20+ 11: "Object.defineProperty() cannot be used on an Immer draft",21+ 12: "Object.setPrototypeOf() cannot be used on an Immer draft",22+ 13: "Immer only supports deleting array indices",23+ 14: "Immer only supports setting array indices and the 'length' property",24+ 15(path: string) {25+ return "Cannot apply patch, path doesn't resolve: " + path26+ },27+ 16: 'Sets cannot have "replace" patches.',28+ 17(op: string) {29+ return "Unsupported patch operation: " + op30+ }31+} as const32+33+export function die(error: keyof typeof errors, ...args: any[]): never {34+ if (__DEV__) {35+ const e = errors[error]36+ const msg = !e37+ ? "unknown error nr: " + error38+ : typeof e === "function"39+ ? e.apply(null, args as any)40+ : e41+ throw new Error(`[Immer] ${msg}`)42+ }43+ throw new Error(44+ `[Immer] minified error nr: ${error}${45+ args.length ? " " + args.join(",") : ""46+ }`47+ )48+}modified:src/finalize.ts+4 added-4 removed
15 unmodified lines16 get,17 ProxyTypeES5Object,18 ProxyTypeES5Array,19 ProxyTypeSet,20- getPlugin20+ getPlugin,21+ die22 } from "./internal"22-import invariant from "tiny-invariant"23 24 export function processResult(result: any, scope: ImmerScope) {25 scope.unfinalizedDrafts_ = scope.drafts_.length26 const baseDraft = scope.drafts_![0]2 unmodified lines29 getPlugin("es5").willFinalizeES5_(scope, result, isReplaced)30 if (isReplaced) {31 if (baseDraft[DRAFT_STATE].modified_) {32 scope.revoke_()33- invariant(false, "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.") // prettier-ignore33+ die(4)34 }35 if (isDraftable(result)) {36 // Finalize the result in case it contains (or is) a subset of the draft.37 result = finalize(scope, result)77 unmodified lines115 prop: string | number,116 childValue: any,117 rootPath?: PatchPath118 ) {119- invariant(childValue !== targetObject, "Immer forbids circular references")119+ if (__DEV__ && childValue === targetObject) die(5)120 if (isDraft(childValue)) {121 const path =122 rootPath &&123 parentState &&39 unmodified linesadded:src/globals.d.ts+1 added
1+declare const __DEV__: booleanmodified:src/immerClass.ts+15 added-19 removed
14 unmodified lines15 isDraft,16 isMap,17 isSet,18 markChangedProxy,19- createProxyProxy19+ createProxyProxy,20+ freeze,21+ getPlugin,22+ die23 } from "./internal"21-import invariant from "tiny-invariant"22-import {freeze} from "./common"23-import {getPlugin} from "./plugins"24 25-declare const __DEV__: boolean25 /* istanbul ignore next */26 function verifyMinified() {}27 28 interface ProducersFns {53 unmodified lines82 return self.produce(base, (draft: Drafted) => recipe.call(this, draft, ...args)) // prettier-ignore83 }84 }85 87- invariant(88- typeof recipe === "function",89- "The first or second argument to `produce` must be a function"90- )91- invariant(92- patchListener === undefined || typeof patchListener === "function",93- "The third argument to `produce` must be a function or undefined"94- )86+ if (__DEV__) {87+ if (typeof recipe !== "function") die(6)88+ if (patchListener !== undefined && typeof patchListener !== "function")89+ die(7)90+ }91 92 let result93 94 // Only plain objects, arrays, and "immerable classes" are drafted.36 unmodified lines131 if (typeof arg1 === "function") {132 return (state: any, ...args: any[]) =>133 this.produceWithPatches(state, (draft: any) => arg1(draft, ...args))134 }139- // non-curried form140- /* istanbul ignore next */141- invariant(!arg3)135+136 let patches: Patch[], inversePatches: Patch[]137 const nextState = this.produce(arg1, arg2, (p: Patch[], ip: Patch[]) => {138 patches = p139 inversePatches = ip1 unmodified line141 return [nextState, patches!, inversePatches!]142 }143 144 createDraft<T extends Objectish>(base: T): Draft<T> {151- invariant(isDraftable(base), "First argument to `createDraft` must be a plain object, an array, or an immerable object") // prettier-ignore145+ if (!isDraftable(base)) die(8)146 const scope = ImmerScope.enter_(this)147 const proxy = createProxy(this, base, undefined)148 proxy[DRAFT_STATE].isManual_ = true149 scope.leave_()4 unmodified lines154 draft: D,155 patchListener?: PatchListener156 ): D extends Draft<infer T> ? T : never {157 const state: ImmerState = draft && draft[DRAFT_STATE]164- invariant(state && state.isManual_, "First argument to `finishDraft` must be a draft returned by `createDraft`") // prettier-ignore165- invariant(!state.finalized_, "The given draft is already finalized") // prettier-ignore158+ if (__DEV__) {159+ if (!state || !state.isManual_) die(9)160+ if (state.finalized_) die(10)161+ }162 const {scope_: scope} = state163 scope.usePatches_(patchListener)164 return processResult(undefined, scope)165 }70 unmodified linesmodified:src/internal.ts+1 added
1 export * from "./env"2+export * from "./errors"3 export * from "./types-external"4 export * from "./types-internal"5 export * from "./common"6 export * from "./plugins"4 unmodified linesmodified:src/proxy.ts+5 added-5 removed
16 unmodified lines17 createProxy,18 ProxyTypeProxyObject,19 ProxyTypeProxyArray20 } from "./internal"21-import invariant from "tiny-invariant"21+import {die} from "./errors"22 23 interface ProxyBaseState extends ImmerBaseState {24 assigned_: {25 [property: string]: boolean160 unmodified lines186 }187 return desc188 },189 defineProperty() {190- invariant(false, "Object.defineProperty() cannot be used on an Immer draft") // prettier-ignore190+ die(11)191 },192 getPrototypeOf(state) {193 return Object.getPrototypeOf(state.base_)194 },195 setPrototypeOf() {196- invariant(false, "Object.setPrototypeOf() cannot be used on an Immer draft") // prettier-ignore196+ die(12)197 }198 }199 200 /**8 unmodified lines209 return fn.apply(this, arguments)210 }211 })212 arrayTraps.deleteProperty = function(state, prop) {213- invariant(!isNaN(parseInt(prop as any)), "Immer only supports deleting array indices") // prettier-ignore213+ if (__DEV__ && isNaN(parseInt(prop as any))) die(13)214 return objectTraps.deleteProperty!.call(this, state[0], prop)215 }216 arrayTraps.set = function(state, prop, value) {217- invariant(prop === "length" || !isNaN(parseInt(prop as any)), "Immer only supports setting array indices and the 'length' property") // prettier-ignore217+ if (__DEV__ && prop !== "length" && isNaN(parseInt(prop as any))) die(14)218 return objectTraps.set!.call(this, state[0], prop, value, state[0])219 }220 221 /**39 unmodified linesmodified:notes.txt+4 added-1 removed
5 unmodified lines6 [x] kill hooks7 [x] _ postfix all members8 [x] clean up finalize9 [x] remove die10-[ ] own invariant10+[x] own invariant11 [ ] update docs12 [ ] plugin tests13 [ ] check if we can create more local vars14 [x] verify performance96 unmodified lines111 3196112 113 add draft optimization114 3199115+116+invariant117+3206modified:package.json-1 removed
74 unmodified lines75 "rimraf": "^2.6.2",76 "seamless-immutable": "^7.1.3",77 "semantic-release": "^17.0.2",78 "spec.ts": "^1.1.0",79- "tiny-invariant": "^1.1.0",79 "ts-jest": "^25.2.0",80 "tsdx": "^0.12.3",81 "typescript": "^3.7.3",82 "webpack": "^4.41.6",3 unmodified linesmodified:tsconfig.json+1 added-1 removed
13 unmodified lines14 "moduleResolution": "node",15 "module": "esnext",16 "allowJs": true17 },18- "files": ["./src/immer.ts", "./src/plugins/es5.ts", "./src/plugins/mapset.ts", "./src/plugins/patches.ts"]18+ "files": ["./src/immer.ts", "./src/plugins/es5.ts", "./src/plugins/mapset.ts", "./src/plugins/patches.ts", "./src/globals.d.ts"]19 }modified:yarn.lock-5 removed
11700 unmodified lines11701 dependencies:11702 globalyzer "^0.1.0"11703 globrex "^0.1.1"11704 11705-tiny-invariant@^1.1.0:11706- version "1.1.0"11707- resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.1.0.tgz#634c5f8efdc27714b7f386c35e6760991d230875"11708- integrity sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw==11709-11705 tiny-relative-date@^1.3.0:11706 version "1.3.0"11707 resolved "https://registry.yarnpkg.com/tiny-relative-date/-/tiny-relative-date-1.3.0.tgz#fa08aad501ed730f31cc043181d995c39a935e07"11708 integrity sha512-MOQHpzllWxDCHHaDno30hhLfbouoYlOI8YlMNtvKe1zXbjEVhbcEovQxvZrPvtiYW630GQDoMMarCnjfyfHA+A==1031 unmodified lines