Skip to content

Commit

Permalink
fix(es/codegen): Accept &impl Node instead of impl Node (#8969)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed May 23, 2024
1 parent 85e4eaa commit a456799
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub type Result = io::Result<()>;
pub fn to_code_default(
cm: Lrc<SourceMap>,
comments: Option<&dyn Comments>,
node: impl Node,
node: &impl Node,
) -> String {
let mut buf = vec![];
{
Expand All @@ -59,12 +59,12 @@ pub fn to_code_default(
}

/// Generate a code from a syntax node using default options.
pub fn to_code_with_comments(comments: Option<&dyn Comments>, node: impl Node) -> String {
pub fn to_code_with_comments(comments: Option<&dyn Comments>, node: &impl Node) -> String {
to_code_default(Default::default(), comments, node)
}

/// Generate a code from a syntax node using default options.
pub fn to_code(node: impl Node) -> String {
pub fn to_code(node: &impl Node) -> String {
to_code_with_comments(None, node)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_transforms_typescript/examples/ts_to_js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ fn main() {
// Ensure that we have enough parenthesis.
let program = module.fold_with(&mut fixer(Some(&comments)));

println!("{}", to_code_default(cm, Some(&comments), program));
println!("{}", to_code_default(cm, Some(&comments), &program));
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn identity(entry: PathBuf) {
Err(_) => return Ok(()),
};

to_code_default(cm.clone(), None, program)
to_code_default(cm.clone(), None, &program)
};

println!("---------------- JS ----------------\n\n{}", js_content);
Expand Down

0 comments on commit a456799

Please sign in to comment.