From 588009ed65349d608d29c6a03e6765b429fd3267 Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Wed, 4 Mar 2026 16:25:55 +0000 Subject: [PATCH] fix(codegen): print `static` keyword for TSIndexSignature (#19755) The codegen was missing the `static` keyword when printing `TSIndexSignature` nodes, causing `static [key: string]: string` index signatures to lose the `static` modifier during code generation. Co-Authored-By: Claude Opus 4.6 --- crates/oxc_codegen/src/gen.rs | 3 +++ crates/oxc_codegen/tests/integration/ts.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index fd89cf7d7071b..3bfba7b80665b 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -3675,6 +3675,9 @@ impl Gen for TSTypeParameterInstantiation<'_> { impl Gen for TSIndexSignature<'_> { fn r#gen(&self, p: &mut Codegen, ctx: Context) { + if self.r#static { + p.print_str("static "); + } if self.readonly { p.print_str("readonly "); } diff --git a/crates/oxc_codegen/tests/integration/ts.rs b/crates/oxc_codegen/tests/integration/ts.rs index 3da76f554bf4f..29a3c90ed0422 100644 --- a/crates/oxc_codegen/tests/integration/ts.rs +++ b/crates/oxc_codegen/tests/integration/ts.rs @@ -39,6 +39,7 @@ fn cases() { ); test_same("class E {\n\tsubscribe!: string;\n}\n"); test_same("class F {\n\taccessor value!: string;\n}\n"); + test_same("class E {\n\tstatic [key: string]: string;\n}\n"); test_same("export { type as as };\n"); test_same("try {} catch (e: unknown) {} finally {}\n"); }