Skip to content
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

Set startPos at EOF in jsdoc token scanner so node end positions for nodes terminated at EoF are right #24184

Merged
15 changes: 9 additions & 6 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6472,12 +6472,15 @@ namespace ts {
}

function isNextNonwhitespaceTokenEndOfFile(): boolean {
nextJSDocToken();
if (token() === SyntaxKind.EndOfFileToken) {
return true;
}
if (token() === SyntaxKind.WhitespaceTrivia || token() === SyntaxKind.NewLineTrivia) {
return lookAhead(isNextNonwhitespaceTokenEndOfFile); // We must use infinte lookahead, as there could be any number of newlines :(
// We must use infinte lookahead, as there could be any number of newlines :(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still has typo 😅

while(true) {
nextJSDocToken();
if (token() === SyntaxKind.EndOfFileToken) {
return true;
}
if (!(token() === SyntaxKind.WhitespaceTrivia || token() === SyntaxKind.NewLineTrivia)) {
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this just return false? If so, I think that's easier to read.

}
}
return false;
}
Expand Down