ui5-community / babel-plugin-transform-modules-ui5

A Babel transformer plugin for OpenUI5/SAPUI5. It allows you to develop UI5 applications by using the latest ECMAScript or TypeScript, including new syntax and objective oriented programming technology.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugin ordering issue with super.method() calls inside an arrow function

r-murphy opened this issue · comments

Issue encountered when running with babel-preset-env when it loads the arrow function transform.

Specifically something like this code where the super call is inside an arrow function.

class Dialog extends SAPDialog {
  fn() {
    setTimeout(() => {
      super.fn();
    }}, 1000);
  }
}

Outputs (where this is wrong):

var D2 = SAPDialog.extend("bchui5.m.D2", {
    fn: function fn() {
        setTimeout(function () {
            SAPDialog.prototype.close.call(this);
        }, 1000);
    }
});

But should be:

var Dialog = SAPDialog.extend("bchui5.m.D2", {
    fn: function fn() {
        var _this = this;
        setTimeout(function () {
            SAPDialog.prototype.close.call(_this);
        }, 1000);
    }
});

Currently the arrow function transform seems to run first.

This is not actually an ordering issue. It was caused by using t.identifier('this') rather than t.thisExpression() so the AST was incorrect for the format expected by the arrow function transform.