-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fixes 6965 #7017
Fixes 6965 #7017
Conversation
perinikhil
commented
Dec 12, 2017
•
edited
Loading
edited
Q | A |
---|---|
Fixed Issues? | Fixes #6965 |
Patch: Bug Fix? | |
Major: Breaking Change? | |
Minor: New Feature? | |
Tests Added + Pass? | Yes |
Documentation PR | |
Any Dependency Changes? | |
License | MIT |
a143a07
to
c8e056c
Compare
const helper = buildApplyDecoratedDescriptor({ | ||
NAME: state.applyDecoratedDescriptor, | ||
}); | ||
const helper = state.addHelper("buildApplyDecoratedDescriptor"); | ||
path.scope.getProgramParent().path.unshiftContainer("body", helper); |
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.
The problem is that these lines:
const helper = buildApplyDecoratedDescriptor({
NAME: state.applyDecoratedDescriptor,
});
path.scope.getProgramParent().path.unshiftContainer("body", helper);
added the helper function to the file.
On the other hand, state.addHelper("buildApplyDecoratedDescriptor");
returns the id of the function (not the function itself), and the helper is added automatically.
So you should just remove the ensure*
functions (which are the equivalent of state.addHelper
), and replace calls to them (like
ensureApplyDecoratedDescriptorHelper(path, state), |
addHelper(" ... ")
.
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.
I see, yes makes sense!
I will update this PR soon after some more digging and tinkering 😃
… to 'babel-helpers'
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6174/ |
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.
Thanks @perinikhil that looks good to me
Thank you @xtuc and @nicolo-ribaudo for your valuable inputs and patience! Much obliged 😃 |
Feel free to merge @nicolo-ribaudo if it looks good to you. @perinikhil, either:
|
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.
Thank you! 🎉
helpers.applyDecoratedDescriptor = defineHelper(` | ||
export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context){ | ||
var desc = {}; | ||
Object['ke' + 'ys'](descriptor).forEach(function(key){ |
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.
what is the problem to use Object.keys(descriptor)
?
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.
It is kept because it was in the original helper, I will check
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.
Because of transform-runtime, same here https://github.com/babel/babel/pull/7017/files/805c8f7cf2dc6eea9d3dcb85b55acc6a6a3334e5#diff-ba75bd4d116cc90ad8c8002e3010e821R762