Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix helpers internal fns names conflict resolution #16130

Merged
merged 2 commits into from Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/babel-helpers/src/index.ts
Expand Up @@ -191,6 +191,7 @@ function permuteHelperAST(

const toRename: Record<string, string> = {};
const bindings = new Set(localBindings || []);
if (id.type === "Identifier") bindings.add(id.name);
localBindingNames.forEach(name => {
let newName = name;
while (bindings.has(newName)) newName = "_" + newName;
Expand Down
@@ -0,0 +1,6 @@
// We'll add the helper `set`. It needs to be renamed to `_set` to avoid
// conflicting with the variable name `set` in this file.
// However, the `set` helper declares a `_set` function itself, which will
// need to be renamed to avoid conflicts.

let set;
@@ -0,0 +1,4 @@
{
"minNodeVersion": "12.22.0",
"plugins": ["./plugin"]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,9 @@
export default function () {
return {
visitor: {
VariableDeclaration(path) {
this.addHelper("set");
},
},
};
}