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

feat(transformer/var-declarations): add insert_var_with_init method #7667

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/oxc_transformer/src/common/var_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ impl<'a> VarDeclarationsStore<'a> {
self.insert_var_binding_pattern(pattern, init, ctx);
}

/// Add a `var` declaration with the given init expression to be inserted at top of
/// current enclosing statement block, given a `BoundIdentifier`.
#[expect(unused)]
#[inline]
pub fn insert_var_with_init(
&self,
binding: &BoundIdentifier<'a>,
init: Expression<'a>,
ctx: &TraverseCtx<'a>,
) {
let pattern = binding.create_binding_pattern(ctx);
self.insert_var_binding_pattern(pattern, Some(init), ctx);
}

/// Create a new [`BoundIdentifier`], add a var declaration to be inserted at the top of
/// the current enclosing statement block, and then return the [`BoundIdentifier`].
#[inline]
Expand Down
Loading