You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
913 B

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _helperPluginUtils = require("@babel/helper-plugin-utils");
  7. var _core = require("@babel/core");
  8. var _default = (0, _helperPluginUtils.declare)(api => {
  9. api.assertVersion(7);
  10. return {
  11. name: "transform-shorthand-properties",
  12. visitor: {
  13. ObjectMethod(path) {
  14. const {
  15. node
  16. } = path;
  17. if (node.kind === "method") {
  18. const func = _core.types.functionExpression(null, node.params, node.body, node.generator, node.async);
  19. func.returnType = node.returnType;
  20. path.replaceWith(_core.types.objectProperty(node.key, func, node.computed));
  21. }
  22. },
  23. ObjectProperty({
  24. node
  25. }) {
  26. if (node.shorthand) {
  27. node.shorthand = false;
  28. }
  29. }
  30. }
  31. };
  32. });
  33. exports.default = _default;