Skip to content

Commit 957d0c3

Browse files
committed
fix(47391): omit | token from jsdoc linkTag text
1 parent 0019c01 commit 957d0c3

File tree

6 files changed

+97
-5
lines changed

6 files changed

+97
-5
lines changed

src/compiler/parser.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8131,8 +8131,15 @@ namespace ts {
81318131
}
81328132
const text = [];
81338133
while (token() !== SyntaxKind.CloseBraceToken && token() !== SyntaxKind.NewLineTrivia && token() !== SyntaxKind.EndOfFileToken) {
8134-
text.push(scanner.getTokenText());
8135-
nextTokenJSDoc();
8134+
// skip |
8135+
if (token() === SyntaxKind.BarToken) {
8136+
nextTokenJSDoc();
8137+
skipWhitespace();
8138+
}
8139+
else {
8140+
text.push(scanner.getTokenText());
8141+
nextTokenJSDoc();
8142+
}
81368143
}
81378144
const create = linkType === "link" ? factory.createJSDocLink
81388145
: linkType === "linkcode" ? factory.createJSDocLinkCode

tests/baselines/reference/jsdocLink1.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
}
142142
},
143143
{
144-
"text": "|postfix text",
144+
"text": "postfix text",
145145
"kind": "linkText"
146146
},
147147
{

tests/baselines/reference/jsdocLink2.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
}
142142
},
143143
{
144-
"text": "|postfix text",
144+
"text": "postfix text",
145145
"kind": "linkText"
146146
},
147147
{

tests/baselines/reference/jsdocLink3.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
}
142142
},
143143
{
144-
"text": "|postfix text",
144+
"text": "postfix text",
145145
"kind": "linkText"
146146
},
147147
{
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoLink4.ts",
5+
"position": 67,
6+
"name": ""
7+
},
8+
"quickInfo": {
9+
"kind": "const",
10+
"kindModifiers": "",
11+
"textSpan": {
12+
"start": 67,
13+
"length": 1
14+
},
15+
"displayParts": [
16+
{
17+
"text": "const",
18+
"kind": "keyword"
19+
},
20+
{
21+
"text": " ",
22+
"kind": "space"
23+
},
24+
{
25+
"text": "B",
26+
"kind": "localName"
27+
},
28+
{
29+
"text": ":",
30+
"kind": "punctuation"
31+
},
32+
{
33+
"text": " ",
34+
"kind": "space"
35+
},
36+
{
37+
"text": "456",
38+
"kind": "stringLiteral"
39+
}
40+
],
41+
"documentation": [
42+
{
43+
"text": "See ",
44+
"kind": "text"
45+
},
46+
{
47+
"text": "{@link ",
48+
"kind": "link"
49+
},
50+
{
51+
"text": "A",
52+
"kind": "linkName",
53+
"target": {
54+
"fileName": "/tests/cases/fourslash/quickInfoLink4.ts",
55+
"textSpan": {
56+
"start": 6,
57+
"length": 7
58+
}
59+
}
60+
},
61+
{
62+
"text": "constant A",
63+
"kind": "linkText"
64+
},
65+
{
66+
"text": "}",
67+
"kind": "link"
68+
},
69+
{
70+
"text": " instead",
71+
"kind": "text"
72+
}
73+
]
74+
}
75+
}
76+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////const A = 123;
4+
/////**
5+
//// * See {@link A | constant A} instead
6+
//// */
7+
////const /**/B = 456;
8+
9+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)