Repository: swc-project/swc (rust)

Issue:
Fails to parse array spread in TSX props `<Foo x={...arr}/>`
### Describe the bug

`swc` fails to parse array spread when it is directly in the prop assignment. Biggest issue is the error message not pointing to the prop, but rather complaining about the whole tag (the outer tag even when the issue is in some nested tag).

### Input code

```typescript
function Component(props: any) {
}

<Component x={...[1,2,3]} />
```



### Config

_No response_

### Playground link

https://play.swc.rs/?version=1.3.36&code=H4sIAAAAAAAAA0srzUsuyczPU3DOzy3Iz0vNK9EoKMovKLZSSMyr1FSo5uWq5eXi5bKBSytU2Fbr6elFG%2BoY6RjH1iro2%2FFyAQB53xVZRQAAAA%3D%3D&config=H4sIAAAAAAAAA0WOSwrDMAxE76J1FsWLLnyHHsK4SnDxD0mBGuO7VzYp2Q0zo6fp8GEPtkN1xEhTccvivmBBWkX2FKrABsJqCZ04VDs6ULSBbB7GaBpLYQS7u8i4QQo57G2yfEmVkPmOXD7ivzmUlcr7nEZf7xbzCeNmXHeBX1dxbfgBaADhoLcAAAA%3D

### Expected behavior

transpilation without errors:
```
function Component(props) {
}
React.createElement(Component, { x: [1, 2, 3] });
```

### Actual behavior

```
  x Unexpected token `Component`. Expected jsx identifier
   ,-[input.tsx:1:1]
 1 | function Component(props: any) {
 2 | }
 3 | 
 4 | <Component x={...[1,2,3]} />
   :  ^^^^^^^^^
   `----


Caused by:
    0: failed to process js file
    1: Syntax Error
```

### Version

1.3.36

### Additional context

The issue can be worked around by using `<Component x={[...[1,2,3]]}`

TS playground link: https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAYTgWwA4IKZigCgwCc4MBnALkQEMwBPASkQG8AoAX1dYB5VMc8iAB4BeZgDpJAbQCMAGgBMcgMwBddogD0APlZA

Pull request description:
FIX: Fails to parse array spread in TSX props <Foo x={...arr}/>
<!-- Note: CI script will automatically rebase your PR so please do not rebase unless required -->

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. -->

**Description:**
You could refer to https://github.com/microsoft/TypeScript/blob/43cc362cef72e5fa1372f59736a9c4b55d85def0/src/compiler/parser.ts#L6107-L6133
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

**BREAKING CHANGE:**

<!--
If this PR introduces a breaking change, it must contain a notice for it to be included in the CHANGELOG. Add description or remove entirely if not breaking.

You may need to update `MIGRATION.md` for the breaking changes.
-->

**Related issue (if exists):**
Fixed #6977 

Patch:
diff --git a/crates/swc_ecma_parser/src/parser/jsx.rs b/crates/swc_ecma_parser/src/parser/jsx.rs
index ebf37b196b..d897866c66 100644
--- a/crates/swc_ecma_parser/src/parser/jsx.rs
+++ b/crates/swc_ecma_parser/src/parser/jsx.rs
@@ -143,6 +143,9 @@ impl<I: Tokens> Parser<I> {
         let expr = if is!(self, '}') {
             self.parse_jsx_empty_expr().map(JSXExpr::JSXEmptyExpr)?
         } else {
+            if is!(self, "...") {
+                bump!(self);
+            }
             self.parse_expr().map(JSXExpr::Expr)?
         };
         expect!(self, '}');


Test patch:
diff --git a/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/1/input.js b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/1/input.js
new file mode 100644
index 0000000000..00b47acafe
--- /dev/null
+++ b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/1/input.js
@@ -0,0 +1,4 @@
+function Component(props) {
+}
+
+<Component x={...[1,2,3]} />
\ No newline at end of file
diff --git a/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/1/output.mjs b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/1/output.mjs
new file mode 100644
index 0000000000..6b74ab0b78
--- /dev/null
+++ b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/1/output.mjs
@@ -0,0 +1,8 @@
+function Component(props) {}
+/*#__PURE__*/ React.createElement(Component, {
+    x: [
+        1,
+        2,
+        3
+    ]
+});
diff --git a/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/2/input.js b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/2/input.js
new file mode 100644
index 0000000000..30539b4375
--- /dev/null
+++ b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/2/input.js
@@ -0,0 +1,4 @@
+function Component(props) {
+}
+
+<Component x={...{a: x}} />
\ No newline at end of file
diff --git a/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/2/output.mjs b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/2/output.mjs
new file mode 100644
index 0000000000..e5a0d99a84
--- /dev/null
+++ b/crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/2/output.mjs
@@ -0,0 +1,6 @@
+function Component(props) {}
+/*#__PURE__*/ React.createElement(Component, {
+    x: {
+        a: x
+    }
+});