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

Don't try to visit ArrowFunctionExpression, they cannot be named #5008

Merged
merged 2 commits into from Jan 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -3,7 +3,7 @@ import nameFunction from "babel-helper-function-name";
export default function () {
return {
visitor: {
"ArrowFunctionExpression|FunctionExpression": {
FunctionExpression: {
exit(path) {
if (path.key !== "value" && !path.parentPath.isObjectProperty()) {
let replacement = nameFunction(path);
Expand Down
@@ -0,0 +1,5 @@
// I don't know if this is a bug with arrow-functions spec: true
// or with function-name, but the functions are missing their names.
const x = () => x;
const y = x => x();
const z = { z: () => y(x) }.z;
@@ -0,0 +1,16 @@
var _this = this;

// I don't know if this is a bug with arrow-functions spec: true
// or with function-name, but the functions are missing their names.
const x = function () {
babelHelpers.newArrowCheck(this, _this);
return x;
}.bind(this);
const y = function (x) {
babelHelpers.newArrowCheck(this, _this);
return x();
}.bind(this);
const z = { z: function z() {
babelHelpers.newArrowCheck(this, _this);
return y(x);
}.bind(this) }.z;
@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-es2015-function-name", [ "transform-es2015-arrow-functions", { "spec": true } ]]
}
@@ -0,0 +1,3 @@
const x = () => x;
const y = x => x();
const z = { z: () => y(x) }.z;
@@ -0,0 +1,9 @@
const x = function x() {
return x;
};
const y = function y(x) {
return x();
};
const z = { z: function z() {
return y(x);
} }.z;
@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-es2015-function-name", "transform-es2015-arrow-functions"]
}
@@ -0,0 +1,2 @@
export const x = ({x}) => x;
export const y = function () {};
@@ -0,0 +1,2 @@
export const x = ({ x }) => x;
export const y = function y() {};
@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-es2015-function-name"]
}