From 564a75ab37f4e73c4ac618e959a7457779d923fa Mon Sep 17 00:00:00 2001 From: michaelm Date: Sat, 6 Jul 2024 01:59:49 -0400 Subject: [PATCH] fix(codegen): missing TypeParameters in TSConstructSignature (#4063) --- crates/oxc_codegen/src/gen.rs | 3 +++ crates/oxc_codegen/tests/mod.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 44702f6ea..d86e0c123 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -3106,6 +3106,9 @@ impl<'a, const MINIFY: bool> Gen for TSSignature<'a> { } Self::TSConstructSignatureDeclaration(signature) => { p.print_str(b"new "); + if let Some(type_parameters) = signature.type_parameters.as_ref() { + type_parameters.gen(p, ctx); + } p.print_str(b"("); signature.params.gen(p, ctx); p.print_str(b")"); diff --git a/crates/oxc_codegen/tests/mod.rs b/crates/oxc_codegen/tests/mod.rs index d214631f9..8d327196f 100644 --- a/crates/oxc_codegen/tests/mod.rs +++ b/crates/oxc_codegen/tests/mod.rs @@ -200,6 +200,7 @@ fn typescript() { false, ); test_ts("let foo: { (t: T): void }", "let foo: {(t: T): void};\n", false); + test_ts("let foo: { new (t: T): void }", "let foo: {new (t: T): void};\n", false); test_ts("function (){}", "function() {}\n", false); test_ts("class A {m?(): void}", "class A {\n\tm?(): void;\n}\n", false); test_ts(