-
Notifications
You must be signed in to change notification settings - Fork 29
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
Allow newline before type inside parens #358
Conversation
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.
Nice catch!
@@ -5255,7 +5255,7 @@ TypePrimary | |||
_? IdentifierName (Dot IdentifierName)* TypeArguments? | |||
# NOTE: Check FunctionType before parenthesized in order to distinguish between (a: T) => U and | |||
# A parenthesized inline interface (a: T) ---> ({a: T}) | |||
__ OpenParen Type __ CloseParen | |||
__ OpenParen ( Type / ( EOS Type ) ) __ CloseParen |
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.
This could be rewritten as follows:
__ OpenParen ( Type / ( EOS Type ) ) __ CloseParen | |
__ OpenParen ( EOS? Type ) __ CloseParen |
Or maybe even simpler:
__ OpenParen ( Type / ( EOS Type ) ) __ CloseParen | |
__ OpenParen __ Type __ CloseParen |
I'm a little confused why Type
doesn't allow leading __
already. Ah, I see, it's because TypePrimary
has lots of _?
prefixes but sometimes-not-always a __
prefix. Seems a bit messy, but this should work...
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 want it to check Type
first to handle nested implicit interfaces. __ Type
would swallow the EOS
and prevent Nested
from matching.
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.
Oh, I see. Interesting! Resolved.
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.
(but maybe worth adding a comment)
No description provided.