Skip to content

Commit 2d09da6

Browse files
authored
allow consecutive newlines in jsdoc tag comments (microsoft#38036)
1 parent 93ccc17 commit 2d09da6

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

src/compiler/parser.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -7440,11 +7440,9 @@ namespace ts {
74407440
loop: while (true) {
74417441
switch (tok) {
74427442
case SyntaxKind.NewLineTrivia:
7443-
if (state >= JSDocState.SawAsterisk) {
7444-
state = JSDocState.BeginningOfLine;
7445-
// don't use pushComment here because we want to keep the margin unchanged
7446-
comments.push(scanner.getTokenText());
7447-
}
7443+
state = JSDocState.BeginningOfLine;
7444+
// don't use pushComment here because we want to keep the margin unchanged
7445+
comments.push(scanner.getTokenText());
74487446
indent = 0;
74497447
break;
74507448
case SyntaxKind.AtToken:

src/testRunner/unittests/jsDocParsing.ts

+6
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ namespace ts {
320320
`/**
321321
* @author John Doe <john.doe@example.com>
322322
* @author John Doe <john.doe@example.com> unexpected comment
323+
*/`);
324+
325+
parsesCorrectly("consecutive newline tokens",
326+
`/**
327+
* @example
328+
* Some\n\n * text\r\n * with newlines.
323329
*/`);
324330
});
325331
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"kind": "JSDocComment",
3+
"pos": 0,
4+
"end": 55,
5+
"flags": "JSDoc",
6+
"modifierFlagsCache": 0,
7+
"transformFlags": 0,
8+
"tags": {
9+
"0": {
10+
"kind": "JSDocTag",
11+
"pos": 7,
12+
"end": 19,
13+
"modifierFlagsCache": 0,
14+
"transformFlags": 0,
15+
"tagName": {
16+
"kind": "Identifier",
17+
"pos": 8,
18+
"end": 15,
19+
"modifierFlagsCache": 0,
20+
"transformFlags": 0,
21+
"escapedText": "example"
22+
},
23+
"comment": "Some\n\ntext\r\nwith newlines."
24+
},
25+
"length": 1,
26+
"pos": 7,
27+
"end": 19,
28+
"hasTrailingComma": false,
29+
"transformFlags": 0
30+
}
31+
}

0 commit comments

Comments
 (0)