-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
[BUG] [Immer 5.0.x] Uncaught TypeError: undefined is not a function (Object.assign) #482
Comments
This code isn't in the sources, so must relate to the transpiler setup :/
…On Tue, Dec 17, 2019 at 5:18 PM Ferry Kobus ***@***.***> wrote:
🐛 Bug Report
On older browsers (mobile) the immer polyfill for Object.assign doesn't
get polyfilled correctly.
The error thrown is super generic. But with debugging boils down to this
code:
function makeTrapsForGetters(getters) {
return Object.assign({}, reflectTraps, {
get: function get(state, prop, receiver) {
return getters.hasOwnProperty(prop) ? getters[prop](state, prop, receiver) : Reflect.get(state, prop, receiver);
},
setPrototypeOf: function setPrototypeOf(state) {
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
}
});
}
Link to repro
Our repro is private.
To Reproduce
Just run immer on an old browser.
We used a HTC ONE M9
Chrome version: 40.0.2214.89
Observed behavior
Crashes completely the application
Expected behavior
Custom polyfill works.
Environment
- *Immer version:*
- Occurs with setUseProxies(true)
- Occurs with setUseProxies(false) (ES5 only)
Workaround,
Use immer 4.0.2. There the polyfill functions as expected.
This issue is created because of this issue that was closed: #477
(comment)
<#477 (comment)>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#482?email_source=notifications&email_token=AAN4NBA2HI7O2LCGI6SDF2DQZECWNA5CNFSM4J362WEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IBDTHUQ>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBGO2ABYWNM62I26T2DQZECWNANCNFSM4J362WEA>
.
|
@egoist ideas? |
@mweststrate You're using object rest spreading here so it gets transpiled to Line 364 in 7a8e4e4
I guess you should change this to use your Line 64 in 7a8e4e4
|
@egoist yeah that is what I assumed, but I guess that means that the transpilation config is off, as that should prevent us against such mistakes? Probably the target ES version is too high? If transpilation doesn't guard us against this we will run into it every time a spread is introduced :) IIRC babel shout emit utility functions for this automatically? |
🎉 This issue has been resolved in version 5.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Pushed a patch, will revisit when finalizing TS conversion. @FBKobus could you confirm version 5.0.02 fixes the issue? |
@mweststrate I will test tomorrow on several old devices and report here the outcome. |
@mweststrate ; hereby I confirm that the bug has been resolved in version 5.0.2. |
Thanks! |
🐛 Bug Report
On older browsers (mobile) the immer polyfill for Object.assign doesn't get polyfilled correctly.
The error thrown is super generic. But with debugging boils down to this code:
Link to repro
Our repro is private.
To Reproduce
Just run immer on an old browser.
We used a HTC ONE M9
Chrome version: 40.0.2214.89
Observed behavior
Crashes completely the application
Expected behavior
Custom polyfill works.
Environment
setUseProxies(true)
setUseProxies(false)
(ES5 only)Workaround,
Use immer 4.0.2. There the polyfill functions as expected.
This issue is created because of this issue that was closed: #477 (comment)
The text was updated successfully, but these errors were encountered: