Skip to content
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

fix destructuring rest with template literal #10013

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/babel-plugin-transform-destructuring/src/index.js
Expand Up @@ -203,6 +203,8 @@ export default declare((api, options) => {
const key = prop.key;
if (t.isIdentifier(key) && !prop.computed) {
keys.push(t.stringLiteral(key.name));
} else if (t.isTemplateLiteral(prop.key)) {
keys.push(t.cloneNode(prop.key));
} else if (t.isLiteral(key)) {
keys.push(t.stringLiteral(String(key.value)));
} else {
Expand Down
@@ -0,0 +1,6 @@
function testOmitProperties(initialObject, testKey) {
var {
[`${testKey}s`]: family,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it was ${i++}? It shouldn't increment it twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently it's handled, updated test case to reflect the edge case.

interestingly, if the variable used, ie: testKey, the property key is pure. but if the variable is not defined, it is unpure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found this comment (#9416 (review)), wonder what is your plan, would like to work on it if I can

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found this comment (#9416 (review)), wonder what is your plan, would like to work on it if I can

I'll talk with the team to check if they are ok with it 👍

...rest
} = initialObject;
}
@@ -0,0 +1,4 @@
function testOmitProperties(initialObject, testKey) {
var family = initialObject[`${testKey}s`],
rest = babelHelpers.objectWithoutProperties(initialObject, [`${testKey}s`]);
}