Skip to content

Commit 8eb87ba

Browse files
authoredMar 17, 2025··
fix(es/ast): Fix Typo in API (#10210)
**Description:** This is a breaking change, so I deprecated it instead of removing it.
1 parent e6c04b4 commit 8eb87ba

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed
 

‎.changeset/new-dancers-remember.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
swc_ecma_ast: patch
3+
swc_ecma_minifier: patch
4+
swc_ecma_transforms_optimization: patch
5+
swc_core: patch
6+
---
7+
8+
AST API

‎crates/swc_ecma_ast/src/expr.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,13 @@ impl Expr {
315315
}
316316
}
317317

318-
/// Returns true for `eval` and member expressions.
318+
#[deprecated(note = "Use `directness_matters` instead")]
319319
pub fn directness_maters(&self) -> bool {
320+
self.directness_matters()
321+
}
322+
323+
/// Returns true for `eval` and member expressions.
324+
pub fn directness_matters(&self) -> bool {
320325
self.is_ident_ref_to("eval") || matches!(self, Expr::Member(..))
321326
}
322327

‎crates/swc_ecma_minifier/src/compress/optimize/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ impl VisitMut for Optimizer<'_> {
24912491
.exprs
24922492
.last()
24932493
.map(|v| &**v)
2494-
.map_or(false, Expr::directness_maters);
2494+
.map_or(false, Expr::directness_matters);
24952495

24962496
let ctx = Ctx {
24972497
dont_use_negated_iife: true,

‎crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl VisitMut for Remover {
354354

355355
let last = e.exprs.pop().unwrap();
356356

357-
let should_preserved_this = last.directness_maters();
357+
let should_preserved_this = last.directness_matters();
358358

359359
let mut exprs = if should_preserved_this {
360360
e.exprs

‎crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl SimplifyExpr {
545545
if !left.may_have_side_effects(self.expr_ctx) {
546546
self.changed = true;
547547

548-
if node.directness_maters() {
548+
if node.directness_matters() {
549549
*expr = SeqExpr {
550550
span: node.span(),
551551
exprs: vec![0.into(), node.take()],
@@ -1250,7 +1250,7 @@ impl VisitMut for SimplifyExpr {
12501250
.exprs
12511251
.last()
12521252
.map(|v| &**v)
1253-
.map_or(false, Expr::directness_maters)
1253+
.map_or(false, Expr::directness_matters)
12541254
{
12551255
match seq.exprs.first().map(|v| &**v) {
12561256
Some(Expr::Lit(..) | Expr::Ident(..)) => {}
@@ -1371,7 +1371,7 @@ impl VisitMut for SimplifyExpr {
13711371

13721372
let expr_value = if val { cons } else { alt };
13731373
*expr = if p.is_pure() {
1374-
if expr_value.directness_maters() {
1374+
if expr_value.directness_matters() {
13751375
SeqExpr {
13761376
span: *span,
13771377
exprs: vec![0.into(), expr_value.take()],
@@ -1730,7 +1730,7 @@ fn nth_char(s: &str, mut idx: usize) -> Option<Cow<str>> {
17301730
}
17311731

17321732
fn need_zero_for_this(e: &Expr) -> bool {
1733-
e.directness_maters() || e.is_seq()
1733+
e.directness_matters() || e.is_seq()
17341734
}
17351735

17361736
/// Gets the value of the given key from the given object properties, if the key

0 commit comments

Comments
 (0)
Please sign in to comment.