From 6790d1d219640f35e4141d65830f92ca18ded15d Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Thu, 9 Jan 2025 02:20:50 +0000 Subject: [PATCH] refactor(transformer/class-properties): simplify determining if class is declaration (#8357) Small improvement. Use `Class::type` field to determine if class is declaration/expression. Not sure why it did it in such a complicated way previously! --- .../oxc_transformer/src/es2022/class_properties/class.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/oxc_transformer/src/es2022/class_properties/class.rs b/crates/oxc_transformer/src/es2022/class_properties/class.rs index eb840692d..dda0bc442 100644 --- a/crates/oxc_transformer/src/es2022/class_properties/class.rs +++ b/crates/oxc_transformer/src/es2022/class_properties/class.rs @@ -65,12 +65,7 @@ impl<'a> ClassProperties<'a, '_> { } // Get basic details about class - let is_declaration = match ctx.ancestor(1) { - Ancestor::ExportDefaultDeclarationDeclaration(_) - | Ancestor::ExportNamedDeclarationDeclaration(_) => true, - grandparent => grandparent.is_parent_of_statement(), - }; - + let is_declaration = *class.r#type() == ClassType::ClassDeclaration; let mut class_name_binding = class.id().as_ref().map(BoundIdentifier::from_binding_ident); let class_scope_id = class.scope_id().get().unwrap(); let has_super_class = class.super_class().is_some();