-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Disable isStartOfType's lookahead when called from isStartOfParameter #18296
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
Conversation
src/compiler/parser.ts
Outdated
@@ -2698,7 +2699,7 @@ namespace ts { | |||
} | |||
} | |||
|
|||
function isStartOfType(): boolean { | |||
function isStartOfType(disableLookahead?: boolean): boolean { |
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.
can we have a more declarative name, like inJSDocType or something?
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.
sure. done.
var tt1 = (a, (b, c)) => a+b+c; | ||
~ | ||
!!! error TS1003: Identifier expected. |
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.
hmm. so we had this test originally? why did not we catch this the first time around then?
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 noticed the baseline change but (1) I thought that removal of 3 errors was actually an improvement (2) didn't think it was indicative on any further problem. I also looked at the emitted code and thought it was better -- closer to what was written at least.
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.
well.. the new error is a parse error. so a bit worse than the 3 semantic ones.
Thanks guys 👍 |
@sandersn can you port this to release-2.5 as well |
It's in release-2.5 now. |
isStartOfType
has lookahead for parenthesized types. Now that unified JSDoc parsing allows types to start parameters, this lookahead compounds with speculative arrow-function parsing's lookahead (which also cares about parentheses). Disable the lookahead whenisStartOfType
is called fromisStartOfParameter
, which was introduced with the addition of unified JSDoc parsing.Fixes #18123