index.js 748 B

123456789101112131415161718192021222324252627282930
  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 _pluginSyntaxOptionalCatchBinding = require("@babel/plugin-syntax-optional-catch-binding");
  8. var _default = (0, _helperPluginUtils.declare)(api => {
  9. api.assertVersion(7);
  10. return {
  11. name: "proposal-optional-catch-binding",
  12. inherits: _pluginSyntaxOptionalCatchBinding.default,
  13. visitor: {
  14. CatchClause(path) {
  15. if (!path.node.param) {
  16. const uid = path.scope.generateUidIdentifier("unused");
  17. const paramPath = path.get("param");
  18. paramPath.replaceWith(uid);
  19. }
  20. }
  21. }
  22. };
  23. });
  24. exports.default = _default;