Transforming IIFE results in extra parentheses #187

Open
ghost opened this Issue Oct 1, 2016 · 2 comments

Projects

None yet

1 participant

@ghost
ghost commented Oct 1, 2016 edited
(function ($) {
  $.name = function (method) {};

  $(document).ready(function () {
    $('.someClass').name();
  });
})(jQuery);

give me

(($ => {
  $.name = method => {};

  $(document).ready(() => {
    $('.someClass').name();
  });
}))(jQuery);

but

($ => {
  $.name = method => {};

  $(document).ready(() => {
    $('.someClass').name();
  });
})(jQuery);

the same

@nene
Collaborator
nene commented Oct 1, 2016 edited

Aha, so the problem is that transforming:

(function(x){ return x })()

produces:

((x => x))()

which has one extra pair of parentheses.

Will take a look, but I suspect that the problem is in Recast, as Lebab itself only changes the abstract syntax tree, while Recast deals with printing it out with all the needed parenthesis.

@nene
Collaborator
nene commented Oct 2, 2016

Opened an issue in Recast: benjamn/recast#327

@nene nene changed the title from Jquery plugin to Transforming IIFE results in extra parentheses Oct 2, 2016
@nene nene added the bug label Oct 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment