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
Don't hoist template literal keys in object-rest-spread
#13483
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,9 @@ | ||||||||||||||||||
const example = () => { | ||||||||||||||||||
const input = {}; | ||||||||||||||||||
const foo = 'foo'; | ||||||||||||||||||
|
||||||||||||||||||
const { | ||||||||||||||||||
[`${foo}_bar`]: country, | ||||||||||||||||||
...rest | ||||||||||||||||||
} = input; | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an object destructure. We need to test an object rest, which is (confusingly) when there's no
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it? I tought both the desturcturing and This test is currently broken on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am so confused by the split between the two plugins… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should definitely consider merging them, relying on the |
||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const example = () => { | ||
const input = {}; | ||
const foo = 'foo'; | ||
const { | ||
[`${foo}_bar`]: country | ||
} = input, | ||
rest = babelHelpers.objectWithoutProperties(input, [`${foo}_bar`]); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag is kinda redundant, you could just set
allLiteral = false
(becaseTemplateLiteral
is most often not literal). Or remove this branch, replace the following condition'sisLiteral
withisImmutable
, and thenTemplateLiteral
would fall through to theelse
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because when
allLiteral
isfalse
we need to inject thetoPropertyKey
helper. We don't need it if we have template literals.