Skip to content

Commit

Permalink
fix(transformer): remove an AstBuilder::copy call from TS namespace…
Browse files Browse the repository at this point in the history
… transform (#4987)

Replace an unsafe `AstBuilder::copy` call with `AstBuilder::move_expression` in TS namespace transform.
  • Loading branch information
overlookmotel committed Aug 19, 2024
1 parent a8dfdda commit 6ffbd78
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/oxc_transformer/src/typescript/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl<'a> TypeScript<'a> {
let Some(property_name) = declarator.id.get_identifier() else {
return;
};
if let Some(init) = &declarator.init {
if let Some(init) = &mut declarator.init {
declarator.init = Some(
self.ctx.ast.expression_assignment(
SPAN,
Expand All @@ -476,8 +476,7 @@ impl<'a> TypeScript<'a> {
),
)
.into(),
// SAFETY: `ast.copy` is unsound! We need to fix.
unsafe { self.ctx.ast.copy(init) },
self.ctx.ast.move_expression(init),
),
);
}
Expand Down

0 comments on commit 6ffbd78

Please sign in to comment.