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

Can't log arrays (TypeError) #50

Closed
hex13 opened this issue Jan 9, 2018 · 3 comments
Closed

Can't log arrays (TypeError) #50

hex13 opened this issue Jan 9, 2018 · 3 comments

Comments

@hex13
Copy link

hex13 commented Jan 9, 2018

immer 0.4.1, Node v8.4.0

const produce = require('immer').default;
produce([],(arr) => { console.log(arr);  });
TypeError: 'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property 'length' that is incompatible with the existing property in the proxy target
    at Function.keys (<anonymous>)
    at formatValue (util.js:392:21)
    at inspect (util.js:236:10)
    at format (util.js:97:24)
    at Console.log (console.js:113:24)
    at immer (repl:1:28)
    at produce (blah/node_modules/immer/immer.js:224:29)
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
@zhw2590582
Copy link

zhw2590582 commented Jan 10, 2018

https://github.com/mweststrate/immer/blob/29e22580849f66311d089a3362972053b1ecbe09/immer.js#L157
When you directly access an array itself, 'length' property is an exception from this, immer attempts to modify the descriptor's configurable property, So TypeError.
How is this? Or delete it?

if (descriptor && (Array.isArray(owner) && prop !== 'length')) descriptor.configurable = true

@mweststrate

@mweststrate
Copy link
Collaborator

@zhw2590582 correct! Forgot that Array.length is as usual an exception to everything :/. working on a fix.

@mweststrate
Copy link
Collaborator

Should be fixed in 0.4.2

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

3 participants