docs(transformer): clarify comment (#7918)

This commit is contained in:
overlookmotel 2024-12-15 15:06:27 +00:00
parent 1317c00a5d
commit f4cb5d3c95

View file

@ -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(