index.js 749 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. exports.skipAllButComputedKey = skipAllButComputedKey;
  7. var _t = require("@babel/types");
  8. const {
  9. VISITOR_KEYS,
  10. staticBlock
  11. } = _t;
  12. function skipAllButComputedKey(path) {
  13. if (!path.node.computed) {
  14. path.skip();
  15. return;
  16. }
  17. const keys = VISITOR_KEYS[path.type];
  18. for (const key of keys) {
  19. if (key !== "key") path.skipKey(key);
  20. }
  21. }
  22. const skipKey = (staticBlock ? "StaticBlock|" : "") + "ClassPrivateProperty|TypeAnnotation|FunctionDeclaration|FunctionExpression";
  23. var _default = {
  24. [skipKey]: path => path.skip(),
  25. "Method|ClassProperty"(path) {
  26. skipAllButComputedKey(path);
  27. }
  28. };
  29. exports.default = _default;