Skip to content

Convert simple arrow function body to expression#616

Merged
boopathi merged 2 commits intobabel:masterfrom
ashsearle:feature/arrow-fn-block-to-sequence
Jul 8, 2017
Merged

Convert simple arrow function body to expression#616
boopathi merged 2 commits intobabel:masterfrom
ashsearle:feature/arrow-fn-block-to-sequence

Conversation

@ashsearle
Copy link
Copy Markdown
Contributor

Eliminate unnecessary return keyword by converting arrow function block statements to expressions where possible.

Example:

const foo = () => {
  return (1, 2);
};
const bar = () => {
  return [];
};

// becomes
const foo = () => (1, 2);
const bar = () => [];

@boopathi boopathi added the Tag: New Feature Pull Request adding a new feature label Jul 7, 2017

if (
t.isArrowFunctionExpression(parent) &&
node.body &&
Copy link
Copy Markdown
Member

@boopathi boopathi Jul 7, 2017

Choose a reason for hiding this comment

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

We are in a BlockStatement - is this check ever falsey ? A BlockStatement's body is always an array.

@boopathi boopathi self-assigned this Jul 7, 2017
@boopathi boopathi merged commit 5e1870b into babel:master Jul 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tag: New Feature Pull Request adding a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants