-
Notifications
You must be signed in to change notification settings - Fork 64
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
Computed property following a spread that's nested under a computed is missing closing parens #139
Comments
const closing = code.slice(beginEnd, end);
code.prependLeft(moveStart, closing);
code.remove(beginEnd, end); The actual culprit is https://github.com/Rich-Harris/buble/blob/master/src/program/types/ObjectExpression.js#L226 . // Before this code runs
var z1 = {; z1[b] = Object.assign({}, c,( obj = {}, obj[d] = 'Hello, World!', obj ))}
// After this code runs
var z1 = {)}; z1[b] = Object.assign({}, c,( obj = {}, obj[d] = 'Hello, World!', obj ) The code above tries to move the closing |
Would you consider submitting a pull request for this? |
I think I tried to fix this before, and I discovered that this was caused by MagicString (which I have not wrapped my head around just yet). It's most likely due to the order of string manipulation/what MagicString thinks was on the original string at some index. I remember that I couldn't reproduce the issue in small scale. |
I think I fixed this, but it's pretty arcane. |
Object.assign
will be missing parens if you assign an object to a computed that has a spread followed by a computed. DemoInput:
Output:
The bug happens regardless of depth. Demo
Input:
Output:
This bug is a blocker especially for those who use a Redux-like approach to recreate state (nested shallow copies).
The text was updated successfully, but these errors were encountered: