Prevent transform-es2015-function-name from altering MethodDefinition's Re: T6779#3149
Prevent transform-es2015-function-name from altering MethodDefinition's Re: T6779#3149jmm wants to merge 2 commits intobabel:masterfrom
Conversation
(Failing.)
Fix T6779. It should be possible to apply this to ES5 functions without mutating ES2015 MethodDefinition's.
Current coverage is
|
|
Ok forgot about super in object literals - right it does look like that has to be in a ObjectMethod. And |
|
@hzoo Cool, thanks for reviewing.
Ironically, since I started this it occurred to me that maybe |
|
I don't understand the issue with regards to |
|
@amasad Thanks for reviewing.
Sorry, that's my fault.
EDIT: it's not so much that the issue report misstates the problem -- as the title says, I think the OP's main point is that it shouldn't transform the
Correct, that's what I'm proposing. As in the fixtures here, Those seem like separate concerns to me and my understanding is that The hypothetical is enough, but recent versions of V8 (Chrome 45 / Node 5) are a perfect example of why I think this behavior makes sense: var x = {
y: function () {},
z () {},
};
console.log(x.y.name); // ""
console.log(x.z.name); // "z" |
|
Cool, can you cite the ES2015 to make sure we're doing the right thing? Browsers often don't fully implement the spec. |
|
@amasad I'm sorry, I muddled this by talking about |
See https://phabricator.babeljs.io/T6779. Looking for feedback on whether this is:
ObjectExpression's and loop all the props / methods, but if just the props are being considered it seems like visitingObjectProperty's makes sense.ObjectExpression) is the only context where anObjectPropertycan appear.My understanding is that transforming an ES2015 object literal method definition (e.g.
{x () {}}) to ES5 has at least one important semantic limitation (regardingsuper-- see the issue). (Someone please confirm.) So it seems to me it ought to be possible to do this:input.jsMy understanding is that
babel-plugin-transform-es2015-shorthand-propertiesis the one that should transform ES2015 like in this example and it seems to me that the user should opt-in to that if they want to transform the method definition syntax and accept the limitations. It should be possible to use both transforms together if you want the outcome thatbabel-plugin-transform-es2015-function-nameon its own is delivering currently with this input, correct? (Actually, now that I think about it, shouldshorthand-propertiesnot automatically name the function when transformingMethodDefinition's?)Existing tests pass with this change, so if this is not the correct behavior the
actualfixture ought to be adopted along with a differentexpected.