-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Use of miniKindOf is not ES5-compliant #4089
Comments
Huh. This is the first I've ever heard that nested functions aren't legal in some cases. Can you point to some kind of a reference for where this restriction is described? |
Same here until I ran into the error and did some research on it. Here are some references:
My understanding of this is that ES5 has extremely loose scoping rules. Normally, the function definition would be hoisted out of the if statement, so in strict mode, they chose to prevent confusion by refusing to allow functions to be declared inside if statements. This error is rarely observed in practice for two reasons:
|
Yeah, definitely a pretty rare edge case :) tbh this is low priority for me atm, as we're focusing on getting the RTK Query APIs out the door. If you'd like to submit a PR that rearranges the code to make this work as expected, we can look at getting that in. |
It can be reproduced in IE10, you'll have an error |
Seems to happen in Safari too: https://stackoverflow.com/questions/68635182/safari-error-functions-cannot-be-declared-in-a-nested-block-in-strict-mode |
Fixes reduxjs#4089 Former-commit-id: 674ef72
Fixes reduxjs#4089 Former-commit-id: 674ef72 Former-commit-id: ea50f9e
Fixes reduxjs#4089 Former-commit-id: 674ef72 Former-commit-id: ea50f9e
Fixes reduxjs#4089 Former-commit-id: 674ef72 Former-commit-id: ea50f9e
Prior Issues
None that I could find.
What is the current behavior?
Redux causes my application to crash on some ES5 browsers because of a nested function within an
if
statement in kindOf.ts. This is not permitted in ES5 and Babel does not seem to provide a transform for this, probably because it would break existing code.The exact console log is this:
SyntaxError: Nested functions cannot be declared in strict mode.
Steps to Reproduce
It's a bit hard to create a live repro case for this, since finding an ES5 browser is difficult nowadays. However, I can provide a gist with my Babel and browserslist configurations as well as a file highlighting the issue.
What is the expected behavior?
Redux should run in an ES5 environment with a standard Babel configuration.
Environment Details
Browser: Midori 0.5.11 on Ubuntu 18.04
The text was updated successfully, but these errors were encountered: