Skip to content

fix(es/parser): Disallow spread operator(...) in JSX attribute values#10587

Merged
kdy1 merged 3 commits intoswc-project:mainfrom
magic-akari:fix/issue-10586
Jun 9, 2025
Merged

fix(es/parser): Disallow spread operator(...) in JSX attribute values#10587
kdy1 merged 3 commits intoswc-project:mainfrom
magic-akari:fix/issue-10586

Conversation

@magic-akari
Copy link
Copy Markdown
Member

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 9, 2025

🦋 Changeset detected

Latest commit: dee04f6

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 9, 2025

CodSpeed Performance Report

Merging #10587 will not alter performance

Comparing magic-akari:fix/issue-10586 (dee04f6) with main (e1f2597)

Summary

✅ 144 untouched benchmarks

@magic-akari
Copy link
Copy Markdown
Member Author

I noticed the spread operator (...) was introduced in this PR.
I'd like to investigate whether this aligns with the intended behavior.

@magic-akari
Copy link
Copy Markdown
Member Author

Alright, I've identified the root cause. TypeScript's parser uses the same parseJsxExpression function for both JSX attributes and children. Since spread syntax (...) isn't valid in JSX attribute positions, this should indeed throw an error.

This was confirmed by TypeScript's fix in microsoft/TypeScript#55284. To align with this behavior, we should update our test cases to treat spread operators in JSX attributes as syntax errors.

@magic-akari magic-akari changed the title fix(es/parser): disallow spread operator in JSX attribute values fix(es/parser): Disallow spread operator(...) in JSX attribute values Jun 9, 2025
@magic-akari magic-akari marked this pull request as ready for review June 9, 2025 10:32
@magic-akari magic-akari requested a review from a team as a code owner June 9, 2025 10:32
@kdy1 kdy1 added this to the Planned milestone Jun 9, 2025
@kdy1 kdy1 self-assigned this Jun 9, 2025
@kdy1 kdy1 requested a review from a team as a code owner June 9, 2025 14:36
@kdy1 kdy1 merged commit 8deba78 into swc-project:main Jun 9, 2025
18 checks passed
@magic-akari magic-akari deleted the fix/issue-10586 branch June 10, 2025 09:45
@kdy1 kdy1 modified the milestones: Planned, v1.12.0 Jun 10, 2025
@swc-project swc-project locked as resolved and limited conversation to collaborators Jul 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

spread jsx attribute value should parse failed but not

2 participants