feat(44956): remove hyphen separator (#47777)

This commit is contained in:
Oleksandr T
2022-02-18 23:41:36 +02:00
committed by GitHub
parent 2477ff915e
commit b0b8cdafc9
10 changed files with 73 additions and 64 deletions

View File

@@ -152,14 +152,23 @@ namespace ts.JsDoc {
function getDisplayPartsFromComment(comment: string | readonly JSDocComment[], checker: TypeChecker | undefined): SymbolDisplayPart[] {
if (typeof comment === "string") {
return [textPart(comment)];
return [textPart(skipSeparatorFromComment(comment))];
}
return flatMap(
comment,
node => node.kind === SyntaxKind.JSDocText ? [textPart(node.text)] : buildLinkParts(node, checker)
node => node.kind === SyntaxKind.JSDocText ? [textPart(skipSeparatorFromComment(node.text))] : buildLinkParts(node, checker)
) as SymbolDisplayPart[];
}
function skipSeparatorFromComment(text: string) {
let pos = 0;
if (text.charCodeAt(pos++) === CharacterCodes.minus) {
while (pos < text.length && text.charCodeAt(pos) === CharacterCodes.space) pos++;
return text.slice(pos);
}
return text;
}
function getCommentDisplayParts(tag: JSDocTag, checker?: TypeChecker): SymbolDisplayPart[] | undefined {
const { comment, kind } = tag;
const namePart = getTagNameDisplayPart(kind);

View File

@@ -386,11 +386,11 @@ x(1)`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "y - {@link C}"
text: "y {@link C}"
}],
documentation: [{
kind: "text",
text: "- "
text: ""
}, {
kind: "link",
text: "{@link "
@@ -425,7 +425,7 @@ x(1)`
text: " "
}, {
kind: "text",
text: "- "
text: ""
}, {
kind: "link",
text: "{@link "
@@ -461,11 +461,11 @@ x(1)`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "y - {@link C}"
text: "y {@link C}"
}],
documentation: [{
kind: "text",
text: "- "
text: ""
}, {
kind: "link",
text: "{@link "
@@ -496,7 +496,7 @@ x(1)`
text: " "
}, {
kind: "text",
text: "- "
text: ""
}, {
kind: "link",
text: "{@link "
@@ -610,7 +610,7 @@ foo`
text: " "
}, {
kind: "text",
text: "- see "
text: "see "
}, {
kind: "link",
text: "{@link "
@@ -641,7 +641,7 @@ foo`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "x - see {@link C}",
text: "x see {@link C}",
}],
});
});
@@ -659,7 +659,7 @@ foo`
text: " "
}, {
kind: "text",
text: "- see "
text: "see "
}, {
kind: "link",
text: "{@link "
@@ -686,7 +686,7 @@ foo`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "x - see {@link C}",
text: "x see {@link C}",
}],
});
});