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