feat(ecmascript): handle pure call expression in chain expressions (#9480)

This commit is contained in:
sapphi-red committed 2025-03-02 12:43:59 +00:00
1 parent 58defe3327
commit 64f4a8220a
2 files changed
+3 -1

No files matched your search

@@ -400,7 +400,7 @@ impl MayHaveSideEffects for ClassElement<'_> {
impl MayHaveSideEffects for ChainElement<'_> {
fn may_have_side_effects(&self, is_global_reference: &impl IsGlobalReference) -> bool {
match self {
ChainElement::CallExpression(_) => true,
ChainElement::CallExpression(e) => e.may_have_side_effects(is_global_reference),
ChainElement::TSNonNullExpression(e) => {
e.expression.may_have_side_effects(is_global_reference)
}
@@ -657,6 +657,8 @@ fn test_call_like_expressions() {
test("/* #__PURE__ */ foo(...`${bar}`)", true);
test("/* #__PURE__ */ foo(...`${bar()}`)", true);
test("/* #__PURE__ */ (() => { foo() })()", false);
test("foo?.()", true);
test("/* #__PURE__ */ foo?.()", false);
test("new Foo()", true);
test("/* #__PURE__ */ new Foo()", false);