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.

1 line
3.3 KiB

{"version":3,"names":["_helperPluginUtils","require","_params","_rest","_default","exports","default","declare","api","options","_api$assumption","_api$assumption2","assertVersion","ignoreFunctionLength","assumption","loose","noNewArrows","name","visitor","Function","path","isArrowFunctionExpression","get","some","param","isRestElement","isAssignmentPattern","arrowFunctionToExpression","allowInsertArrowWithRest","isFunctionExpression","convertedRest","convertFunctionRest","convertedParams","convertFunctionParams","scope","crawl"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport convertFunctionParams from \"./params.ts\";\nimport convertFunctionRest from \"./rest.ts\";\nexport { convertFunctionParams };\n\nexport interface Options {\n loose?: boolean;\n}\n\nexport default declare((api, options: Options) => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n const ignoreFunctionLength =\n api.assumption(\"ignoreFunctionLength\") ?? options.loose;\n // Todo(BABEL 8): Consider default it to false\n const noNewArrows = api.assumption(\"noNewArrows\") ?? true;\n\n return {\n name: \"transform-parameters\",\n\n visitor: {\n Function(path) {\n if (\n path.isArrowFunctionExpression() &&\n path\n .get(\"params\")\n .some(param => param.isRestElement() || param.isAssignmentPattern())\n ) {\n // default/rest visitors require access to `arguments`, so it cannot be an arrow\n path.arrowFunctionToExpression({\n allowInsertArrowWithRest: false,\n noNewArrows,\n });\n\n // In some cases arrowFunctionToExpression replaces the function with a wrapper.\n // Return early; the wrapped function will be visited later in the AST traversal.\n if (!path.isFunctionExpression()) return;\n }\n\n const convertedRest = convertFunctionRest(path);\n const convertedParams = convertFunctionParams(\n path,\n ignoreFunctionLength,\n );\n\n if (convertedRest || convertedParams) {\n // Manually reprocess this scope to ensure that the moved params are updated.\n path.scope.crawl();\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA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