Skip to content

Commit d808a71

Browse files
committed
fix(codegen): add support for printing type arguments in new expressions
1 parent 0146b4c commit d808a71

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

crates/oxc_codegen/src/gen.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,9 @@ impl GenExpr for NewExpression<'_> {
22022202
p.print_str("new");
22032203
p.print_soft_space();
22042204
self.callee.print_expr(p, Precedence::New, Context::FORBID_CALL);
2205+
if let Some(type_parameters) = &self.type_arguments {
2206+
type_parameters.print(p, ctx);
2207+
}
22052208

22062209
// Omit the "()" when minifying, but only when safe to do so
22072210
if !p.options.minify || !self.arguments.is_empty() || precedence >= Precedence::Postfix

crates/oxc_codegen/tests/integration/ts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn ts() {
6868
"a = x!;",
6969
"b = (x as y);",
7070
"c = foo<string>;",
71+
"new Map<string, number>();",
7172
"d = x satisfies y;",
7273
"export @x declare abstract class C {}",
7374
"div<T>``",

0 commit comments

Comments
 (0)