From eee20efc867e4ca95ed9f6516f949b6ca2da8eb7 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 21 Oct 2024 14:12:49 +0800 Subject: [PATCH 1/3] fix(ast): `ClassElement::r#static` should return `true` for static block --- crates/oxc_ast/src/ast_impl/js.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index c7368b6124489..e8d16bf07cd04 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -1307,10 +1307,11 @@ impl<'a> ClassElement<'a> { /// static modifier. pub fn r#static(&self) -> bool { match self { - Self::TSIndexSignature(_) | Self::StaticBlock(_) => false, + Self::ClassElement(_) => true, Self::MethodDefinition(def) => def.r#static, Self::PropertyDefinition(def) => def.r#static, Self::AccessorProperty(def) => def.r#static, + Self::TSIndexSignature(_) => false, } } From 3a4117f80ca6334b7c94350e4e728e7d20689645 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 21 Oct 2024 14:48:02 +0800 Subject: [PATCH 2/3] fix --- crates/oxc_ast/src/ast_impl/js.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index e8d16bf07cd04..733e4c3ff73fc 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -1307,7 +1307,7 @@ impl<'a> ClassElement<'a> { /// static modifier. pub fn r#static(&self) -> bool { match self { - Self::ClassElement(_) => true, + Self::StaticBlock(_) => true, Self::MethodDefinition(def) => def.r#static, Self::PropertyDefinition(def) => def.r#static, Self::AccessorProperty(def) => def.r#static, From a739f5458a5c8c88ad4218464db7ff283b810f6e Mon Sep 17 00:00:00 2001 From: _Kerman Date: Tue, 22 Oct 2024 17:55:46 +0800 Subject: [PATCH 3/3] fix: revert change and fix comment --- crates/oxc_ast/src/ast_impl/js.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index 733e4c3ff73fc..22fb682aacb9e 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -1303,15 +1303,14 @@ impl<'a> ClassElement<'a> { matches!(self, Self::StaticBlock(_)) } - /// Returns `true` if this [`ClassElement`] is a static block or has a + /// Returns `true` if this [`ClassElement`] is a property and has a /// static modifier. pub fn r#static(&self) -> bool { match self { - Self::StaticBlock(_) => true, + Self::TSIndexSignature(_) | Self::StaticBlock(_) => false, Self::MethodDefinition(def) => def.r#static, Self::PropertyDefinition(def) => def.r#static, Self::AccessorProperty(def) => def.r#static, - Self::TSIndexSignature(_) => false, } }