fix(codegen): missing TypeParameters in TSConstructSignature (#4063)

This commit is contained in:
michaelm 2024-07-06 01:59:49 -04:00 committed by GitHub
parent 1b8f208572
commit 564a75ab37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -3106,6 +3106,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> 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")");

View file

@ -200,6 +200,7 @@ fn typescript() {
false,
);
test_ts("let foo: { <T>(t: T): void }", "let foo: {<T>(t: T): void};\n", false);
test_ts("let foo: { new <T>(t: T): void }", "let foo: {new <T>(t: T): void};\n", false);
test_ts("function <const T>(){}", "function<const T>() {}\n", false);
test_ts("class A {m?(): void}", "class A {\n\tm?(): void;\n}\n", false);
test_ts(