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.

40 lines
1.0 KiB

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 _params = _interopRequireDefault(require("./params"));
  8. var _rest = _interopRequireDefault(require("./rest"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. var _default = (0, _helperPluginUtils.declare)((api, options) => {
  11. api.assertVersion(7);
  12. const {
  13. loose
  14. } = options;
  15. return {
  16. name: "transform-parameters",
  17. visitor: {
  18. Function(path) {
  19. if (path.isArrowFunctionExpression() && path.get("params").some(param => param.isRestElement() || param.isAssignmentPattern())) {
  20. path.arrowFunctionToExpression();
  21. }
  22. const convertedRest = (0, _rest.default)(path);
  23. const convertedParams = (0, _params.default)(path, loose);
  24. if (convertedRest || convertedParams) {
  25. path.scope.crawl();
  26. }
  27. }
  28. }
  29. };
  30. });
  31. exports.default = _default;