diff --git a/crates/swc_ecma_codegen/src/typescript.rs b/crates/swc_ecma_codegen/src/typescript.rs index 2c73cb79ddf6..c60b133f650b 100644 --- a/crates/swc_ecma_codegen/src/typescript.rs +++ b/crates/swc_ecma_codegen/src/typescript.rs @@ -100,6 +100,10 @@ where self.emit_leading_comments_of_span(n.span(), false)?; keyword!("new"); + if let Some(type_params) = &n.type_params { + space!(); + emit!(type_params); + } punct!("("); self.emit_list(n.span, Some(&n.params), ListFormat::Parameters)?; @@ -122,8 +126,8 @@ where } keyword!("new"); - space!(); if let Some(type_params) = &n.type_params { + space!(); emit!(type_params); } diff --git a/crates/swc_ecma_codegen/tests/fixture/issues/7079/input.ts b/crates/swc_ecma_codegen/tests/fixture/issues/7079/input.ts new file mode 100644 index 000000000000..f7309f09fd2e --- /dev/null +++ b/crates/swc_ecma_codegen/tests/fixture/issues/7079/input.ts @@ -0,0 +1,3 @@ +interface Foo { + new (value: T): Obj; +} diff --git a/crates/swc_ecma_codegen/tests/fixture/issues/7079/output.ts b/crates/swc_ecma_codegen/tests/fixture/issues/7079/output.ts new file mode 100644 index 000000000000..02e85c6cbc9a --- /dev/null +++ b/crates/swc_ecma_codegen/tests/fixture/issues/7079/output.ts @@ -0,0 +1,3 @@ +interface Foo { + new (value: T): Obj; +} diff --git a/crates/swc_ecma_transforms_base/tests/ts-resolver/stc/1/output.ts b/crates/swc_ecma_transforms_base/tests/ts-resolver/stc/1/output.ts index 106c79d40a59..20b97579d4ac 100644 --- a/crates/swc_ecma_transforms_base/tests/ts-resolver/stc/1/output.ts +++ b/crates/swc_ecma_transforms_base/tests/ts-resolver/stc/1/output.ts @@ -4,7 +4,7 @@ interface Mixin1__1 { class AbstractBase__1 { abstractBaseMethod(): void; } -function Mixin2__1 any>(baseClass__2: TBase__2) { +function Mixin2__1 any>(baseClass__2: TBase__2) { class MixinClass__2 extends baseClass__2 implements Mixin1__1 { mixinMethod(): void {} static staticMixinMethod(): void {}