Repository: swc-project/swc (rust)

Issue:
SWC could not parse `() => <Component<any>></Component>` while tsc could
### Describe the bug

tsc: https://www.typescriptlang.org/play?target=99&ts=5.0.4#code/BQSgBAvAfGA8DCB7AtgB0QOwKYYC6wEMMBPKKWAeiTUx1yiA

### Input code

```typescript
() => <Component<any>></Component>
```


### Config

_No response_

### Playground link

https://play.swc.rs/?version=1.3.59&code=H4sIAAAAAAAAA9PQVLC1U7Bxzs8tyM9LzSuxScyrtLOz0YcL2HEBABELyhojAAAA&config=H4sIAAAAAAAAA02OvQ6DMAyEd54i8tyhytChbxOlpgoiEPmM1Ajx7nWgPyyW7zv7dGvnHA2IdHerrSZKELD8tBHUScPLCGktjCipKF2%2BrqJZKgvvZDsM0iBP1vbE8FfvPw%2BU05T6eo6Pcy7CgLE%2BjDjF7IPy%2FFhG%2FhdsJY7cG7WjbnsDOkAxqsUAAAA%3D

### Expected behavior


```js
"use strict";
() => React.createElement(Component, null);
```

### Actual behavior

```

  x Unexpected token `Component`. Expected jsx identifier
   ,-[input.tsx:1:1]
 1 | () => <Component<any>></Component>
   :        ^^^^^^^^^
   `----


Caused by:
    0: failed to process js file
    1: Syntax Error
```

### Version

1.3.59

### Additional context

This should be a regression, we don't hit the problem in the previous version.

Pull request:
fix(es/parser): Fix parsing of generic jsx element name
**Description:**

**Related issue:**

 - Closes #7444.

Patch:
diff --git a/crates/swc_ecma_parser/src/parser/jsx.rs b/crates/swc_ecma_parser/src/parser/jsx.rs
index 696cfa4f81..cb6af38dce 100644
--- a/crates/swc_ecma_parser/src/parser/jsx.rs
+++ b/crates/swc_ecma_parser/src/parser/jsx.rs
@@ -205,7 +205,11 @@ impl<I: Tokens> Parser<I> {
             }));
         }
 
-        let name = self.parse_jsx_element_name()?;
+        let ctx = Context {
+            should_not_lex_lt_or_gt_as_type: false,
+            ..self.ctx()
+        };
+        let name = self.with_ctx(ctx).parse_jsx_element_name()?;
         self.parse_jsx_opening_element_after_name(start, name)
             .map(Either::Right)
     }
@@ -289,6 +293,7 @@ impl<I: Tokens> Parser<I> {
 
         let ctx = Context {
             in_forced_jsx_context: forced_jsx_context,
+            should_not_lex_lt_or_gt_as_type: false,
             ..self.ctx()
         };
         self.with_ctx(ctx).parse_with(|p| {


Test patch:
diff --git a/crates/swc_ecma_parser/tests/typescript/issue-7444/1/input.tsx b/crates/swc_ecma_parser/tests/typescript/issue-7444/1/input.tsx
new file mode 100644
index 0000000000..bb870d5e1a
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript/issue-7444/1/input.tsx
@@ -0,0 +1,1 @@
+() => <Component<any>></Component>
diff --git a/crates/swc_ecma_parser/tests/typescript/issue-7444/1/input.tsx.json b/crates/swc_ecma_parser/tests/typescript/issue-7444/1/input.tsx.json
new file mode 100644
index 0000000000..20088ef745
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript/issue-7444/1/input.tsx.json
@@ -0,0 +1,98 @@
+{
+  "type": "Script",
+  "span": {
+    "start": 1,
+    "end": 35,
+    "ctxt": 0
+  },
+  "body": [
+    {
+      "type": "ExpressionStatement",
+      "span": {
+        "start": 1,
+        "end": 35,
+        "ctxt": 0
+      },
+      "expression": {
+        "type": "ArrowFunctionExpression",
+        "span": {
+          "start": 1,
+          "end": 35,
+          "ctxt": 0
+        },
+        "params": [],
+        "body": {
+          "type": "JSXElement",
+          "span": {
+            "start": 7,
+            "end": 35,
+            "ctxt": 0
+          },
+          "opening": {
+            "type": "JSXOpeningElement",
+            "name": {
+              "type": "Identifier",
+              "span": {
+                "start": 8,
+                "end": 17,
+                "ctxt": 0
+              },
+              "value": "Component",
+              "optional": false
+            },
+            "span": {
+              "start": 7,
+              "end": 23,
+              "ctxt": 0
+            },
+            "attributes": [],
+            "selfClosing": false,
+            "typeArguments": {
+              "type": "TsTypeParameterInstantiation",
+              "span": {
+                "start": 17,
+                "end": 22,
+                "ctxt": 0
+              },
+              "params": [
+                {
+                  "type": "TsKeywordType",
+                  "span": {
+                    "start": 18,
+                    "end": 21,
+                    "ctxt": 0
+                  },
+                  "kind": "any"
+                }
+              ]
+            }
+          },
+          "children": [],
+          "closing": {
+            "type": "JSXClosingElement",
+            "span": {
+              "start": 23,
+              "end": 35,
+              "ctxt": 0
+            },
+            "name": {
+              "type": "Identifier",
+              "span": {
+                "start": 25,
+                "end": 34,
+                "ctxt": 0
+              },
+              "value": "Component",
+              "optional": false
+            }
+          }
+        },
+        "async": false,
+        "generator": false,
+        "typeParameters": null,
+        "returnType": null
+      }
+    }
+  ],
+  "interpreter": null
+}