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
[ts] Allow ...<...>
followed by newline or binary operator
#14636
Conversation
// a<b> | ||
// if (0); | ||
// is not valid TS code (https://github.com/microsoft/TypeScript/issues/48654) | ||
// However, it should correctly parse anything that is correctly parsed by TS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linked issue has been fixed.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52199/ |
...<...>
followed by newline and strict keyword...<...>
followed by newline or binary operator
177201b
to
2d85950
Compare
2d85950
to
c5b12b3
Compare
// a<b>c is (a<b)>c | ||
(tokenType !== tt.parenL && | ||
tokenCanStartExpression(tokenType) && | ||
!this.hasPrecedingLineBreak()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have this test (still passing) which is relevant: https://github.com/babel/babel/tree/main/packages/babel-parser/test/fixtures/typescript/type-arguments/call-newline
@@ -9,36 +9,40 @@ | |||
"body": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if these changes are correct; I asked to the TS team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the updates are correct: https://www.typescriptlang.org/play?ts=4.8.0-dev.20220611#code%2FHYUw7gBAggPAQgPgFAGEg=
I'll rename the test.
I'm marking this PR as a draft until the TS PR is merged with the final syntax rules.