rewrite-this.js 684 B

12345678910111213141516171819202122232425262728293031
  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. function rewriteThis(programPath) {
  8. programPath.traverse(rewriteThisVisitor);
  9. }
  10. const rewriteThisVisitor = {
  11. ThisExpression(path) {
  12. path.replaceWith(path.scope.buildUndefinedNode());
  13. },
  14. Function(path) {
  15. if (path.isMethod()) (0, _helperReplaceSupers.skipAllButComputedKey)(path);else if (!path.isArrowFunctionExpression()) path.skip();
  16. },
  17. ClassProperty(path) {
  18. (0, _helperReplaceSupers.skipAllButComputedKey)(path);
  19. },
  20. ClassPrivateProperty(path) {
  21. path.skip();
  22. }
  23. };