allow consecutive newlines in jsdoc tag comments (#38036)

This commit is contained in:
Michael Hensler 2020-07-02 15:19:37 -06:00 committed by GitHub
parent 93ccc17658
commit 2d09da6df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 5 deletions

View File

@ -7440,11 +7440,9 @@ namespace ts {
loop: while (true) {
switch (tok) {
case SyntaxKind.NewLineTrivia:
if (state >= JSDocState.SawAsterisk) {
state = JSDocState.BeginningOfLine;
// don't use pushComment here because we want to keep the margin unchanged
comments.push(scanner.getTokenText());
}
state = JSDocState.BeginningOfLine;
// don't use pushComment here because we want to keep the margin unchanged
comments.push(scanner.getTokenText());
indent = 0;
break;
case SyntaxKind.AtToken:

View File

@ -320,6 +320,12 @@ namespace ts {
`/**
* @author John Doe <john.doe@example.com>
* @author John Doe <john.doe@example.com> unexpected comment
*/`);
parsesCorrectly("consecutive newline tokens",
`/**
* @example
* Some\n\n * text\r\n * with newlines.
*/`);
});
});

View File

@ -0,0 +1,31 @@
{
"kind": "JSDocComment",
"pos": 0,
"end": 55,
"flags": "JSDoc",
"modifierFlagsCache": 0,
"transformFlags": 0,
"tags": {
"0": {
"kind": "JSDocTag",
"pos": 7,
"end": 19,
"modifierFlagsCache": 0,
"transformFlags": 0,
"tagName": {
"kind": "Identifier",
"pos": 8,
"end": 15,
"modifierFlagsCache": 0,
"transformFlags": 0,
"escapedText": "example"
},
"comment": "Some\n\ntext\r\nwith newlines."
},
"length": 1,
"pos": 7,
"end": 19,
"hasTrailingComma": false,
"transformFlags": 0
}
}