From 6254a4106febe6ea3160dbd176077717f0726d51 Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:10:15 +0000 Subject: [PATCH] fix(codegen): missing TypeParamters in TSCallSignature (#4021) close: #4015 --- 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 26d2a278de324..9672ad0769a80 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -3073,6 +3073,9 @@ impl<'a, const MINIFY: bool> Gen for TSSignature<'a> { } } Self::TSCallSignatureDeclaration(signature) => { + if let Some(type_parameters) = signature.type_parameters.as_ref() { + type_parameters.gen(p, ctx); + } p.print_str(b"("); if let Some(this_param) = &signature.this_param { this_param.gen(p, ctx); diff --git a/crates/oxc_codegen/tests/mod.rs b/crates/oxc_codegen/tests/mod.rs index ba8742becf6ea..c6df2b62c59c6 100644 --- a/crates/oxc_codegen/tests/mod.rs +++ b/crates/oxc_codegen/tests/mod.rs @@ -199,6 +199,7 @@ fn typescript() { "class A {\n\treadonly type = 'frame';\n}\n", false, ); + test_ts("let foo: { (t: T): void }", "let foo: {(t: T): void};\n", false); } fn test_comment_helper(source_text: &str, expected: &str) {