Skip to content

Commit

Permalink
fix(codegen): print TSFunctionType inside TSTypeAssertion (#3999)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jul 1, 2024
1 parent 34e8cfc commit 23038ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3488,6 +3488,11 @@ impl<'a, const MINIFY: bool> GenExpr<MINIFY> 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 = < <T>(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);
Expand Down
3 changes: 1 addition & 2 deletions tasks/coverage/codegen_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 23038ad

Please sign in to comment.