Skip to content

Commit

Permalink
Do not consider arguments in a helper as a global reference (#16268)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 26, 2024
1 parent 69858ba commit f7a1ec9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/babel-helpers/src/index.ts
Expand Up @@ -110,7 +110,9 @@ function getHelperMetadata(file: File): HelperMetadata {
const name = child.node.name;
const binding = child.scope.getBinding(name);
if (!binding) {
globals.add(name);
if (name !== "arguments" || child.scope.path.isProgram()) {
globals.add(name);
}
} else if (dependencies.has(binding.identifier)) {
importBindingsReferences.push(makePath(child));
}
Expand Down
@@ -0,0 +1 @@
var arguments;
@@ -0,0 +1,4 @@
{
"plugins": ["./plugin"],
"minNodeVersion": "12.0.0"
}
@@ -0,0 +1,2 @@
function _assertClassBrand(e, t, n) { if ("function" == typeof t ? t === e : t.has(e)) return arguments.length < 3 ? e : n; throw new TypeError("Private element is not present on this object"); }
var arguments;
@@ -0,0 +1,9 @@
export default function () {
return {
visitor: {
Program(path, file) {
file.addHelper("assertClassBrand");
},
},
};
}

0 comments on commit f7a1ec9

Please sign in to comment.