Skip to content

Commit

Permalink
docs(transformer): clarify comment (#7918)
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Dec 15, 2024
1 parent 1317c00 commit f4cb5d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/oxc_transformer/src/common/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ impl<'a> TransformCtx<'a> {
let references = create_array(|| expr.clone_in(ctx.ast.allocator));
return (expr, references);
}
// Template literal can have no side effects if it has no expressions
// Template literal cannot have side effects if it has no expressions.
// If it *does* have expressions, but they're all literals, then also cannot have side effects,
// but don't bother checking for that as it shouldn't occur in real world code.
// Why would you write "`x${9}z`" when you can just write "`x9z`"?
// Note: "`x${foo}`" *can* have side effects if `foo` is an object with a `valueOf` method.
Expression::TemplateLiteral(lit) if lit.expressions.is_empty() => {
let references = create_array(|| {
ctx.ast.expression_template_literal(
Expand Down

0 comments on commit f4cb5d3

Please sign in to comment.