-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Code rewriting breaks function name inferencing #1543
Comments
NOTE: my only work-around for now is I've had to use a full named function in my parameter default: function foo(fn = function fn() { return 1; }) {
fn.name; // "fn" always even with NYC code rewriting
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link to bug demonstration repository
nyc-bug-demo
Expected Behavior
I expect that the code-rewriting that NYC does will not interfere with expected language behavior, specifically the name inference that occurs when an anonymous arrow function is assigned via a "default parameter value" in a function definition:
Observed Behavior
If you clone the linked bug demo repo, and run the tests normally (
node test.js
), it works fine, because the name inference works. But then when you run the same tests via NYC, the tests fail.NYC rewrites the code in a way that loses this
"fn"
name inference, such that the value is""
instead (because it's an anonymous function). My test relies on that proper name inference, as it's a standard part of the JS language behavior.Troubleshooting steps
cache: false
in my nyc configEnvironment Information
The text was updated successfully, but these errors were encountered: