rewrite-this.js 621 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = rewriteThis;
  6. var _helperReplaceSupers = require("@babel/helper-replace-supers");
  7. var _traverse = require("@babel/traverse");
  8. var t = require("@babel/types");
  9. function rewriteThis(programPath) {
  10. (0, _traverse.default)(programPath.node, Object.assign({}, rewriteThisVisitor, {
  11. noScope: true
  12. }));
  13. }
  14. const rewriteThisVisitor = _traverse.default.visitors.merge([_helperReplaceSupers.environmentVisitor, {
  15. ThisExpression(path) {
  16. path.replaceWith(t.unaryExpression("void", t.numericLiteral(0), true));
  17. }
  18. }]);