source: trip-planner-front/node_modules/@babel/preset-modules/lib/plugins/transform-edge-default-parameters/index.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.default = void 0;
5
6/**
7 * Converts destructured parameters with default values to non-shorthand syntax.
8 * This fixes the only arguments-related bug in ES Modules-supporting browsers (Edge 16 & 17).
9 * Use this plugin instead of @babel/plugin-transform-parameters when targeting ES Modules.
10 */
11var _default = ({
12 types: t
13}) => {
14 const isArrowParent = p => p.parentKey === "params" && p.parentPath && t.isArrowFunctionExpression(p.parentPath);
15
16 return {
17 name: "transform-edge-default-parameters",
18 visitor: {
19 AssignmentPattern(path) {
20 const arrowArgParent = path.find(isArrowParent);
21
22 if (arrowArgParent && path.parent.shorthand) {
23 // In Babel 7+, there is no way to force non-shorthand properties.
24 path.parent.shorthand = false;
25 (path.parent.extra || {}).shorthand = false; // So, to ensure non-shorthand, rename the local identifier so it no longer matches:
26
27 path.scope.rename(path.parent.key.name);
28 }
29 }
30
31 }
32 };
33};
34
35exports.default = _default;
36module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.