-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
x</x>/
fails to parse
#51649
Comments
Why would you ever write code like this? Any practical example? |
@MartinJohns A parser error is a parser error; it indicates a bug. If TS wants to remain a superset of JS it must parse all valid JS as JS. This seems like a lexing error; I'm not sure if the TS lexer follows the ES model, but the first |
I'd argue the team has better things to do than to make sure some obscure code that's never really written works. Resources are finite. |
Given that the code parses successfully when adding a space after the I think there have been similar bugs in the past caused by parsing ambiguities that were deliberately not fixed (or at least not completely) due to design limitations in the parser, so I could definitely see "nobody would write this code" being the justification given for not fixing it. See for example #16241 (an extreme example where the JS and TS interpretations of the code are mutually exclusive) which looks like it did get fixed but took several years and a few attempts to do so. |
Reminds me of to #33639, which was considered "won't fix" even though it does technically mean that TS isn't exactly a superset of JS. |
Originally I thought it was confused with instantiation expressions; but ambiguity with JSX seems harder to fix (albeit not impossible). However, #33639 was due to actual grammar ambiguity, but this one is simply a faulty lexer. (Easier said than done though; I don't know if it's trivial to fix, but should be fixable without fumbling with different ambiguous grammar extensions) |
If someone can fix this without negative side effects, feel free to send a PR, but this is just a "You tried to break it on purpose and were successful" situation. |
someone pick up that phone because I called it |
Bug Report
π Search Terms
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
There is a parse error for a perfectly valid expression
π Expected behavior
It should instead parse the expression as
This is the behavior that is found in Babel and ESBuild.
The text was updated successfully, but these errors were encountered: