mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(transformer/var-declarations): add insert_var_with_init method (#7667)
part of #7668
This commit is contained in:
parent
0ca10e270a
commit
e8518e942c
1 changed files with 14 additions and 0 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in a new issue