-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Regression: Cannot parse arrow fn exprs in conditional expr cons and alt in object literals in TypeScript #4067
Comments
I think the patch for #2174 was removed for some reasons, but I don't remember the PR removed it. |
It was in #3685. I think it's reasonable that this doesn't parse in TS given that the TS compiler can't figure it out, but it should still at least parse in JS. |
@dsherret this does parse as JS. The playground you shared has language set to Typescript see |
@williamtetlow yup, I missed that and my bad! I think though that we should still try to support this in TS because it might be fixed in tsc in the future.
|
I just went to report this to TypeScript's repo and at the last second I discovered it is fixed in the latest TS nightly: https://ts-ast-viewer.com/#code/MYewdgzgLgBAHjAvDA3gKBpmAHATibALhilwFcBTDLGgfhgDMwkA+GAChRgF8BKamoJjEmrEuQoAaNNwDcQA (select |
No probs 🙂 For context, I can see why TSC doesn't support it at the moment as it's quite a difficult issue to fix. The following will parse as we can tell that what comes after the true ? fn => { } : fn => 1 but when parsing true ? fn => ({ }) : fn => true This bit |
Oh ok let me take a look at how they fixed it |
It looks like pretty simple fix they just do the opposite now 😄 I can take a look |
@williamtetlow oh nice! Thanks so much for looking into this 🙂 |
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
Regression of #2174
#3685 (comment)
This syntax no longer parses, yet it is valid JavaScript.
Maybe the TS compiler can't figure out how to parse it right now(Edit: it can figure this out now), but it works in V8.https://astexplorer.net/#/gist/d8417911fb6ea22a87b63d441b2a0e87/20b56c10cf6e34b3e7ddc60e9328702e09c930fd
cc @williamtetlow
Input code
Config
No response
Playground link
https://play.swc.rs/?version=1.2.151&code=H4sIAAAAAAAAA0vOzysuUahQsFWo5uVSAIKCovwCK4WSotJUCB8E7BXS8hRs7RQ0qhVqNRHCIGAFlQJp0OHlqrUGAGjLrV1RAAAA&config=H4sIAAAAAAAAA0WOQQ6DMAwE%2F%2BIz1%2FaQP%2FCIKBiUipDIa6RGiL%2FXoaG9edfeWR%2F0QiB3UPECljahburf5EhrYQSJRWkghVmzX8GnCS8Lq50wHrZbcwaTU9l5oBS3ONcGCjkVYaDnbOW3ZeUbY5yUp70Zx9V18Z7Gg0oM%2Bot95Zgn%2Fn9wt%2FSTiLGj2hPnBwXfhU7WAAAA
Expected behavior
Should parse.
Actual behavior
Version
1.2.151
Additional context
No response
The text was updated successfully, but these errors were encountered: