dop251 / goja

ECMAScript/JavaScript engine in pure Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get original position of error?

kimkit opened this issue · comments

I use babel compile src from es6 to es5 with sourceMaps, but I can't get the original position of error.

es6

class index {
  add(a, b) {
    return a + b;
  }
}

let obj = new index();
console.log(obj.addx(1, 2));

es5

"use strict";

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

var index = /*#__PURE__*/function () {
  function index() {
    _classCallCheck(this, index);
  }

  _createClass(index, [{
    key: "add",
    value: function add(a, b) {
      return a + b;
    }
  }]);

  return index;
}();

var obj = new index();
console.log(obj.addx(1, 2));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJpbmRleCIsImEiLCJiIiwib2JqIiwiY29uc29sZSIsImxvZyIsImFkZHgiXSwic291cmNlcyI6WyJ1bmtub3duIl0sInNvdXJjZXNDb250ZW50IjpbImNsYXNzIGluZGV4IHtcbiAgYWRkKGEsIGIpIHtcbiAgICByZXR1cm4gYSArIGI7XG4gIH1cbn1cblxubGV0IG9iaiA9IG5ldyBpbmRleCgpO1xuY29uc29sZS5sb2cob2JqLmFkZHgoMSwgMikpO1xuIl0sIm1hcHBpbmdzIjoiOzs7Ozs7OztJQUFNQSxLOzs7Ozs7O1dBQ0osYUFBSUMsQ0FBSixFQUFPQyxDQUFQLEVBQVU7TUFDUixPQUFPRCxDQUFDLEdBQUdDLENBQVg7SUFDRDs7Ozs7O0FBR0gsSUFBSUMsR0FBRyxHQUFHLElBQUlILEtBQUosRUFBVjtBQUNBSSxPQUFPLENBQUNDLEdBQVIsQ0FBWUYsR0FBRyxDQUFDRyxJQUFKLENBQVMsQ0FBVCxFQUFZLENBQVosQ0FBWiJ9

error

TypeError: Object has no member 'addx' at /index.js:25:21(21)

my mistake, no problem.