Skip to content

Commit b0b8cda

Browse files
authored
feat(44956): remove hyphen separator (microsoft#47777)
1 parent 2477ff9 commit b0b8cda

10 files changed

+73
-64
lines changed

Diff for: src/services/jsDoc.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,23 @@ namespace ts.JsDoc {
152152

153153
function getDisplayPartsFromComment(comment: string | readonly JSDocComment[], checker: TypeChecker | undefined): SymbolDisplayPart[] {
154154
if (typeof comment === "string") {
155-
return [textPart(comment)];
155+
return [textPart(skipSeparatorFromComment(comment))];
156156
}
157157
return flatMap(
158158
comment,
159-
node => node.kind === SyntaxKind.JSDocText ? [textPart(node.text)] : buildLinkParts(node, checker)
159+
node => node.kind === SyntaxKind.JSDocText ? [textPart(skipSeparatorFromComment(node.text))] : buildLinkParts(node, checker)
160160
) as SymbolDisplayPart[];
161161
}
162162

163+
function skipSeparatorFromComment(text: string) {
164+
let pos = 0;
165+
if (text.charCodeAt(pos++) === CharacterCodes.minus) {
166+
while (pos < text.length && text.charCodeAt(pos) === CharacterCodes.space) pos++;
167+
return text.slice(pos);
168+
}
169+
return text;
170+
}
171+
163172
function getCommentDisplayParts(tag: JSDocTag, checker?: TypeChecker): SymbolDisplayPart[] | undefined {
164173
const { comment, kind } = tag;
165174
const namePart = getTagNameDisplayPart(kind);

Diff for: src/testRunner/unittests/tsserver/jsdocTag.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ x(1)`
386386
displayPartsForJSDoc: false,
387387
tags: [{
388388
name: "param",
389-
text: "y - {@link C}"
389+
text: "y {@link C}"
390390
}],
391391
documentation: [{
392392
kind: "text",
393-
text: "- "
393+
text: ""
394394
}, {
395395
kind: "link",
396396
text: "{@link "
@@ -425,7 +425,7 @@ x(1)`
425425
text: " "
426426
}, {
427427
kind: "text",
428-
text: "- "
428+
text: ""
429429
}, {
430430
kind: "link",
431431
text: "{@link "
@@ -461,11 +461,11 @@ x(1)`
461461
displayPartsForJSDoc: false,
462462
tags: [{
463463
name: "param",
464-
text: "y - {@link C}"
464+
text: "y {@link C}"
465465
}],
466466
documentation: [{
467467
kind: "text",
468-
text: "- "
468+
text: ""
469469
}, {
470470
kind: "link",
471471
text: "{@link "
@@ -496,7 +496,7 @@ x(1)`
496496
text: " "
497497
}, {
498498
kind: "text",
499-
text: "- "
499+
text: ""
500500
}, {
501501
kind: "link",
502502
text: "{@link "
@@ -610,7 +610,7 @@ foo`
610610
text: " "
611611
}, {
612612
kind: "text",
613-
text: "- see "
613+
text: "see "
614614
}, {
615615
kind: "link",
616616
text: "{@link "
@@ -641,7 +641,7 @@ foo`
641641
displayPartsForJSDoc: false,
642642
tags: [{
643643
name: "param",
644-
text: "x - see {@link C}",
644+
text: "x see {@link C}",
645645
}],
646646
});
647647
});
@@ -659,7 +659,7 @@ foo`
659659
text: " "
660660
}, {
661661
kind: "text",
662-
text: "- see "
662+
text: "see "
663663
}, {
664664
kind: "link",
665665
text: "{@link "
@@ -686,7 +686,7 @@ foo`
686686
displayPartsForJSDoc: false,
687687
tags: [{
688688
name: "param",
689-
text: "x - see {@link C}",
689+
text: "x see {@link C}",
690690
}],
691691
});
692692
});

Diff for: tests/baselines/reference/jsDocFunctionSignatures6.baseline

+32-32
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"name": "p1",
5353
"documentation": [
5454
{
55-
"text": "- A string param",
55+
"text": "A string param",
5656
"kind": "text"
5757
}
5858
],
@@ -81,7 +81,7 @@
8181
"name": "p2",
8282
"documentation": [
8383
{
84-
"text": "- An optional param",
84+
"text": "An optional param",
8585
"kind": "text"
8686
}
8787
],
@@ -110,7 +110,7 @@
110110
"name": "p3",
111111
"documentation": [
112112
{
113-
"text": "- Another optional param",
113+
"text": "Another optional param",
114114
"kind": "text"
115115
}
116116
],
@@ -143,7 +143,7 @@
143143
"name": "p4",
144144
"documentation": [
145145
{
146-
"text": "- An optional param with a default value",
146+
"text": "An optional param with a default value",
147147
"kind": "text"
148148
}
149149
],
@@ -187,7 +187,7 @@
187187
"kind": "space"
188188
},
189189
{
190-
"text": "- A string param",
190+
"text": "A string param",
191191
"kind": "text"
192192
}
193193
]
@@ -204,7 +204,7 @@
204204
"kind": "space"
205205
},
206206
{
207-
"text": "- An optional param",
207+
"text": "An optional param",
208208
"kind": "text"
209209
}
210210
]
@@ -221,7 +221,7 @@
221221
"kind": "space"
222222
},
223223
{
224-
"text": "- Another optional param",
224+
"text": "Another optional param",
225225
"kind": "text"
226226
}
227227
]
@@ -238,7 +238,7 @@
238238
"kind": "space"
239239
},
240240
{
241-
"text": "- An optional param with a default value",
241+
"text": "An optional param with a default value",
242242
"kind": "text"
243243
}
244244
]
@@ -308,7 +308,7 @@
308308
"name": "p1",
309309
"documentation": [
310310
{
311-
"text": "- A string param",
311+
"text": "A string param",
312312
"kind": "text"
313313
}
314314
],
@@ -337,7 +337,7 @@
337337
"name": "p2",
338338
"documentation": [
339339
{
340-
"text": "- An optional param",
340+
"text": "An optional param",
341341
"kind": "text"
342342
}
343343
],
@@ -366,7 +366,7 @@
366366
"name": "p3",
367367
"documentation": [
368368
{
369-
"text": "- Another optional param",
369+
"text": "Another optional param",
370370
"kind": "text"
371371
}
372372
],
@@ -399,7 +399,7 @@
399399
"name": "p4",
400400
"documentation": [
401401
{
402-
"text": "- An optional param with a default value",
402+
"text": "An optional param with a default value",
403403
"kind": "text"
404404
}
405405
],
@@ -443,7 +443,7 @@
443443
"kind": "space"
444444
},
445445
{
446-
"text": "- A string param",
446+
"text": "A string param",
447447
"kind": "text"
448448
}
449449
]
@@ -460,7 +460,7 @@
460460
"kind": "space"
461461
},
462462
{
463-
"text": "- An optional param",
463+
"text": "An optional param",
464464
"kind": "text"
465465
}
466466
]
@@ -477,7 +477,7 @@
477477
"kind": "space"
478478
},
479479
{
480-
"text": "- Another optional param",
480+
"text": "Another optional param",
481481
"kind": "text"
482482
}
483483
]
@@ -494,7 +494,7 @@
494494
"kind": "space"
495495
},
496496
{
497-
"text": "- An optional param with a default value",
497+
"text": "An optional param with a default value",
498498
"kind": "text"
499499
}
500500
]
@@ -564,7 +564,7 @@
564564
"name": "p1",
565565
"documentation": [
566566
{
567-
"text": "- A string param",
567+
"text": "A string param",
568568
"kind": "text"
569569
}
570570
],
@@ -593,7 +593,7 @@
593593
"name": "p2",
594594
"documentation": [
595595
{
596-
"text": "- An optional param",
596+
"text": "An optional param",
597597
"kind": "text"
598598
}
599599
],
@@ -622,7 +622,7 @@
622622
"name": "p3",
623623
"documentation": [
624624
{
625-
"text": "- Another optional param",
625+
"text": "Another optional param",
626626
"kind": "text"
627627
}
628628
],
@@ -655,7 +655,7 @@
655655
"name": "p4",
656656
"documentation": [
657657
{
658-
"text": "- An optional param with a default value",
658+
"text": "An optional param with a default value",
659659
"kind": "text"
660660
}
661661
],
@@ -699,7 +699,7 @@
699699
"kind": "space"
700700
},
701701
{
702-
"text": "- A string param",
702+
"text": "A string param",
703703
"kind": "text"
704704
}
705705
]
@@ -716,7 +716,7 @@
716716
"kind": "space"
717717
},
718718
{
719-
"text": "- An optional param",
719+
"text": "An optional param",
720720
"kind": "text"
721721
}
722722
]
@@ -733,7 +733,7 @@
733733
"kind": "space"
734734
},
735735
{
736-
"text": "- Another optional param",
736+
"text": "Another optional param",
737737
"kind": "text"
738738
}
739739
]
@@ -750,7 +750,7 @@
750750
"kind": "space"
751751
},
752752
{
753-
"text": "- An optional param with a default value",
753+
"text": "An optional param with a default value",
754754
"kind": "text"
755755
}
756756
]
@@ -820,7 +820,7 @@
820820
"name": "p1",
821821
"documentation": [
822822
{
823-
"text": "- A string param",
823+
"text": "A string param",
824824
"kind": "text"
825825
}
826826
],
@@ -849,7 +849,7 @@
849849
"name": "p2",
850850
"documentation": [
851851
{
852-
"text": "- An optional param",
852+
"text": "An optional param",
853853
"kind": "text"
854854
}
855855
],
@@ -878,7 +878,7 @@
878878
"name": "p3",
879879
"documentation": [
880880
{
881-
"text": "- Another optional param",
881+
"text": "Another optional param",
882882
"kind": "text"
883883
}
884884
],
@@ -911,7 +911,7 @@
911911
"name": "p4",
912912
"documentation": [
913913
{
914-
"text": "- An optional param with a default value",
914+
"text": "An optional param with a default value",
915915
"kind": "text"
916916
}
917917
],
@@ -955,7 +955,7 @@
955955
"kind": "space"
956956
},
957957
{
958-
"text": "- A string param",
958+
"text": "A string param",
959959
"kind": "text"
960960
}
961961
]
@@ -972,7 +972,7 @@
972972
"kind": "space"
973973
},
974974
{
975-
"text": "- An optional param",
975+
"text": "An optional param",
976976
"kind": "text"
977977
}
978978
]
@@ -989,7 +989,7 @@
989989
"kind": "space"
990990
},
991991
{
992-
"text": "- Another optional param",
992+
"text": "Another optional param",
993993
"kind": "text"
994994
}
995995
]
@@ -1006,7 +1006,7 @@
10061006
"kind": "space"
10071007
},
10081008
{
1009-
"text": "- An optional param with a default value",
1009+
"text": "An optional param with a default value",
10101010
"kind": "text"
10111011
}
10121012
]

0 commit comments

Comments
 (0)