Skip to content

Commit bf6a3d3

Browse files
committed
docs(transformer): clarify comment (#7918)
1 parent 1317c00 commit bf6a3d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/oxc_transformer/src/common/duplicate.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ impl<'a> TransformCtx<'a> {
122122
let references = create_array(|| expr.clone_in(ctx.ast.allocator));
123123
return (expr, references);
124124
}
125-
// Template literal can have no side effects if it has no expressions
125+
// Template literal cannot have side effects if it has no expressions.
126+
// If it *does* have expressions, but they're all literals, then cannot have side effects,
127+
// but don't bother checking for that as it shouldn't occur in real world code.
128+
// Why would you write "`x${9}z`" when you can just write "`x9z`"?
129+
// Note: "`x${foo}`" *can* have side effects if `foo` is an object with a `valueOf` method.
126130
Expression::TemplateLiteral(lit) if lit.expressions.is_empty() => {
127131
let references = create_array(|| {
128132
ctx.ast.expression_template_literal(

0 commit comments

Comments
 (0)