-
-
Notifications
You must be signed in to change notification settings - Fork 9.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
Unexpected token delete with addon-actions #1123
Comments
Hey @silvenon Still we could maybe come up with a way of actually supporting this.. I'll mark this as a bug. |
Thanks! I have no problem changing this to a non-reserved word, it just took me a while to realize what's wrong, 😅 I wanted to create this issue so that other users figure this out more easily. Thanks for all your hard work on Storybook! ❤️ 🍻 |
I had the same issue, thanks for raising this and for the discussion ! 👍 I'll add that this is a new behaviour, as my stories with a |
Digging a bit, it comes from the eval here. At this point I don't see why getting the proper (as in ES6-proper) function name is important here, I tried changing the code to an unnamed function and the action log worked fine with my |
Did you change, transpile and then run the code? Reading the comments it sounds like there was a problem with the transpiled code, and this was a hack to solve that issue. Good find! |
I wonder what babel does that the comment is referring to. When I put x = { delete: function() {} } in here: https://babeljs.io it produces the sensible: x = { delete: function _delete() {} } |
@ndelangen no, I changed the transpiled code directly (in my node_modules folder) to experiment. I wanted to see if using an anonymous function would change anything to my actions logging in storybook - but it didn't. @tmeasday I modified your sample to something slightly different and more similar to the code we run today:
The babel output then changes to something that uses |
Good point @gouegd! After some hunting, I discovered the rationale: storybook-eol/storybook-addon-actions#24 |
I would suggest the tradeoff isn't worth it here! But it's hard to go back.. |
In that case a prefix like Another solution I can think of is to put the |
The prefix seems like a good move to me. Maybe @gnarf could weigh in, just in case we missed something? |
Maybe prefix it |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 60 days. Thanks! |
All suggested solutions sound great to me. Anyone want to pick this up and create a PR? |
I think we can actually replace the eval with something like this:
This will probably allow to enable some transforms in #1733 which are currently disabled |
@Hypnosphi the eval was intentionally put there to avoid Object.defineProperty as you can see in the code comment. However I do not see the current workaround as particularly useful, as expressed here |
Actually, the comment mentions a completely different
But babel transpiles it to following:
Here, the You can see that As for the question why the name is needed at all, the main benefit is that it's visible in error stacktraces which simplifies debugging. |
Well, when I said it was "put there to avoid Object.defineProperty", I can hardly see it as a completely different thing than what the comment mentioned as "but babel transpiles to Object.defineProperty" Anyway, good points otherwise 👍 |
My point is that the |
Fixed in |
I'm using the alpha version.
This results in the following error:
The text was updated successfully, but these errors were encountered: