fix(codegen): print TSFunctionType inside TSTypeAssertion (#3999)

This commit is contained in:
Boshen 2024-07-01 14:44:35 +00:00
parent 34e8cfc9e5
commit 23038ad8f8
2 changed files with 6 additions and 2 deletions

View file

@ -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);

View file

@ -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"