Skip to content

Commit

Permalink
fix(transformer): remove an AstBuilder::copy call from TS module tr…
Browse files Browse the repository at this point in the history
…ansform
  • Loading branch information
overlookmotel committed Aug 19, 2024
1 parent 2c7055f commit 8bd496d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions crates/oxc_transformer/src/typescript/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,12 @@ impl<'a> TypeScript<'a> {
) -> Expression<'a> {
match type_name {
TSTypeName::IdentifierReference(ident) => {
let mut ident = ident.clone();
ident.reference_flag = ReferenceFlag::Read;
if let Some(reference_id) = ident.reference_id.get() {
let reference = ctx.symbols_mut().get_reference_mut(reference_id);
*reference.flag_mut() = ReferenceFlag::Read;
} else {
unreachable!()
}
// SAFETY: `ast.copy` is unsound! We need to fix.
self.ctx.ast.expression_from_identifier_reference(unsafe { ctx.ast.copy(ident) })
let reference_id = ident.reference_id.get().unwrap();
let reference = ctx.symbols_mut().get_reference_mut(reference_id);
*reference.flag_mut() = ReferenceFlag::Read;
self.ctx.ast.expression_from_identifier_reference(ident)
}
TSTypeName::QualifiedName(qualified_name) => self
.ctx
Expand Down

0 comments on commit 8bd496d

Please sign in to comment.