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

Object.hasOwn is not a function on safari v14.1 #2304

Closed
MisterFISHUP opened this issue Nov 30, 2022 · 2 comments · Fixed by #2309
Closed

Object.hasOwn is not a function on safari v14.1 #2304

MisterFISHUP opened this issue Nov 30, 2022 · 2 comments · Fixed by #2309
Labels
bug Something isn't working

Comments

@MisterFISHUP
Copy link

React version: 18.2.0

Next.js version: 13.0.1

TypeScript version: 4.8.4

Rest Hooks version: rest-hooks 6.4.2 and @rest-hooks/rest 5.2.0

Package manager version: yarn 1.22.19

Node version: 16.16.0

Describe the bug

Hi,

On some old safari (14.1.2), I encounter this runtime error: Object.hasOwn is not a function (from NetworkManager.js), which I think comes from this commit bdbc6a4. I'm also not sure why this problem exists since it's supposed to be handled by some transcompiler.

I know Object.hasOwn is too new for safari v14.1, but I'm looking for a solution without upgrading the browser.

hasOwn

My tsconfig has esnext in compilerOptions.lib and I've tried using babel-plugin-transform-object-hasown but it didn't solve the problem.

I've also tried to downgrade rest hooks to some versions earlier than the commit above (bdbc6a4), e.g. rest-hooks 6.3.11 and @rest-hooks/rest 5.1.1 (or even older versions), but it seems that @rest-hooks/core 3.4.0 is always installed (in node_modules) and thus the problem still persists. (How can I install rest hooks without having the Object.hasOwn syntax inside? Maybe it could be one of the easiest solutions.)

To Reproduce

The problem is from a private repo so I can't share it here. I'm using next.js v13 with ts v4.8. I think as long as Object.hasOwn is somewhere in the installed dependencies the error will be thrown.

Expected behavior

No this Object.hasOwn error on Safari v14.1.


P.S. Thanks for this awesome project!

@MisterFISHUP MisterFISHUP added the bug Something isn't working label Nov 30, 2022
@ntucker
Copy link
Collaborator

ntucker commented Dec 1, 2022

Thanks for the report @MisterFISHUP !

I'm looking into updating the transpiling process to include imports to the core-js polyfill in the "exports" output.

In the meantime, you can handle this by adding import "core-js"; to the entrypoint of your application. This should include the needed polyfills automatically. If your babel config uses preset-env, this should also ensure only needed polyfills are included.

@ntucker
Copy link
Collaborator

ntucker commented Dec 5, 2022

Should be fixed in rest-hooks@6.6.2 or 7 @MisterFISHUP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants