Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6365,17 +6365,14 @@ namespace ts {
indent += text.length;
}

let t = nextJSDocToken();
while (t === SyntaxKind.WhitespaceTrivia) {
t = nextJSDocToken();
}
if (t === SyntaxKind.NewLineTrivia) {
nextJSDocToken();
while (parseOptionalJsdoc(SyntaxKind.WhitespaceTrivia));
if (parseOptionalJsdoc(SyntaxKind.NewLineTrivia)) {
state = JSDocState.BeginningOfLine;
indent = 0;
t = nextJSDocToken();
}
loop: while (true) {
switch (t) {
switch (token()) {
case SyntaxKind.AtToken:
if (state === JSDocState.BeginningOfLine || state === JSDocState.SawAsterisk) {
removeTrailingNewlines(comments);
Expand Down Expand Up @@ -6435,12 +6432,11 @@ namespace ts {
pushComment(scanner.getTokenText());
break;
}
t = nextJSDocToken();
nextJSDocToken();
}
removeLeadingNewlines(comments);
removeTrailingNewlines(comments);
result = createJSDocComment();

});

return result;
Expand Down Expand Up @@ -6877,8 +6873,7 @@ namespace ts {
jsdocSignature.parameters = append(jsdocSignature.parameters as MutableNodeArray<JSDocParameterTag>, child);
}
const returnTag = tryParse(() => {
if (token() === SyntaxKind.AtToken) {
nextJSDocToken();
if (parseOptionalJsdoc(SyntaxKind.AtToken)) {
const tag = parseTag(indent);
if (tag && tag.kind === SyntaxKind.JSDocReturnTag) {
return tag as JSDocReturnTag;
Expand Down Expand Up @@ -6997,12 +6992,12 @@ namespace ts {
let constraint: JSDocTypeExpression | undefined;
if (token() === SyntaxKind.OpenBraceToken) {
constraint = parseJSDocTypeExpression();
skipWhitespace();
}

const typeParameters = [];
const typeParametersPos = getNodePos();
while (true) {
do {
skipWhitespace();
const typeParameter = <TypeParameterDeclaration>createNode(SyntaxKind.TypeParameter);
if (!tokenIsIdentifierOrKeyword(token())) {
parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
Expand All @@ -7012,15 +7007,7 @@ namespace ts {
skipWhitespace();
finishNode(typeParameter);
typeParameters.push(typeParameter);
if (token() === SyntaxKind.CommaToken) {
// need to look for more type parameters
nextJSDocToken();
skipWhitespace();
}
else {
break;
}
}
} while (parseOptionalJsdoc(SyntaxKind.CommaToken));

if (constraint) {
first(typeParameters).constraint = constraint.type;
Expand All @@ -7038,6 +7025,14 @@ namespace ts {
return currentToken = scanner.scanJSDocToken();
}

function parseOptionalJsdoc(t: JsDocSyntaxKind): boolean {
if (token() === t) {
nextJSDocToken();
return true;
}
return false;
}

function parseJSDocEntityName(): EntityName {
let entity: EntityName = parseJSDocIdentifierName(/*createIfMissing*/ true);
if (parseOptional(SyntaxKind.OpenBracketToken)) {
Expand Down