New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SWC produces invalid code if types have a trailing coma #6589
Comments
ts playground does the same |
@alexander-akait in your example TSC produces the following error:
Also, input in your example is invalid, the issue with SWC is a bit different. Given valid input, SWC produces invalid output. |
Yeah, I see, let's fix it 👍 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
If types contain a trailing coma, swc adds to the actual code, which is a syntax error.
For reference, TSC handles it correctly. TSC playground ref.
Input code
Config
Playground link
https://play.swc.rs/?version=1.3.21&code=H4sIAAAAAAAAA0utKMgvKlFIK81LLsnMzwMzNKq5FBQSdYBEEojQ09MrSi0u4aq1UgBLWCkUlxRl5qWDFSA4tZog6eT8vOL8nFS9nPx0jUSdJB0FkFZNrloAL7Tel2gAAAA%3D&config=H4sIAAAAAAAAAxWKQQqAMAwE%2F7JnD5JjfxNKFEWkZHNoKfm79TYzzMTNijLR1Gn%2BE8cb2lEQoxmrXy2wIbjSoQ8tl6ifFmsxyi6CzA%2Br99KJSAAAAA%3D%3D
Expected behavior
SWC should not add trailing coma after
...rest
Actual behavior
SWC adds trailing coma:
{ a, b, ...rest,}
, which isn't valid syntaxVersion
1.3.21
Additional context
The issue goes away if trailing coma from types is removed.
The text was updated successfully, but these errors were encountered: