butternut icon indicating copy to clipboard operation
butternut copied to clipboard

Omit return statements that don't have an argument or return undefined

Open Rich-Harris opened this issue 7 years ago • 0 comments

This already happens in simple cases:

// input
function foo () {
  console.log(1);
  return;
  console.log(2);
}

// output
function foo(){console.log(1)}

But it fails if there's a declaration after the return, even an unused one:

// input
function foo () {
  console.log(1);
  return;
  console.log(2);

  function x () {}
}

// output
function foo(){console.log(1);return}

Rich-Harris avatar May 16 '17 18:05 Rich-Harris