diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 0559aaec1c8b4..26d2a278de324 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -3488,6 +3488,11 @@ impl<'a, const MINIFY: bool> GenExpr for TSTypeAssertion<'a> { fn gen_expr(&self, p: &mut Codegen<{ MINIFY }>, precedence: Precedence, ctx: Context) { p.wrap(precedence > self.precedence(), |p| { p.print_str(b"<"); + // var r = < (x: T) => T > ((x) => { return null; }); + // ^ make sure space is printed here. + if matches!(self.type_annotation, TSType::TSFunctionType(_)) { + p.print_hard_space(); + } self.type_annotation.gen(p, ctx); p.print_str(b">"); self.expression.gen_expr(p, Precedence::Grouping, ctx); diff --git a/tasks/coverage/codegen_typescript.snap b/tasks/coverage/codegen_typescript.snap index 961ed773afea9..40c83a4c391d1 100644 --- a/tasks/coverage/codegen_typescript.snap +++ b/tasks/coverage/codegen_typescript.snap @@ -2,8 +2,7 @@ commit: d8086f14 codegen_typescript Summary: AST Parsed : 5283/5283 (100.00%) -Positive Passed: 5279/5283 (99.92%) -Normal failed: "compiler/genericTypeAssertions3.ts" +Positive Passed: 5280/5283 (99.94%) Normal failed: "compiler/jsxMultilineAttributeStringValues.tsx" Normal failed: "compiler/jsxMultilineAttributeValuesReact.tsx" Normal failed: "conformance/jsx/tsxReactEmitEntities.tsx"