perf(transformer): skip static block dispatch for ordinary statements (#27491)

Ordinary statements cannot contain the class declaration handled by ES2022 statement-entry dispatch. Check the statement kind before loading class-transform state, admitting only class declarations, export declarations, and default export declarations.

Step 2 of 3 replacing #27446. Parent: #27489. Next: #27492. [Graphite stack](https://app.graphite.com/github/pr/oxc-project/oxc/27489).

AI assistance was used for this change.
This commit is contained in:
camc314 committed 2026-10-10 03:37:23 +00:00
1 parent 135dd04397
commit cd9a62f6fa
1 file changed
+8
+8
View File
@@ -44,6 +44,14 @@ impl ES2022<'_> {
impl<'a> Traverse<'a, TransformState<'a>> for ES2022<'a> {
fn enter_statement(&mut self, stmt: &mut Statement<'a>, ctx: &mut TraverseCtx<'a>) {
if !matches!(
stmt,
Statement::ClassDeclaration(_)
| Statement::ExportDeclaration(_)
| Statement::ExportDefaultDeclaration(_)
) {
return;
}
if let Some(class_static_block) = &mut self.class_static_block {
class_static_block.enter_statement(stmt, ctx);
}