mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #38489 from microsoft/removeDuplicateInfo
Remove duplicate JSDoc comments
This commit is contained in:
@@ -129,6 +129,22 @@ namespace ts {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new array with `element` interspersed in between each element of `input`
|
||||
* if there is more than 1 value in `input`. Otherwise, returns the existing array.
|
||||
*/
|
||||
export function intersperse<T>(input: T[], element: T): T[] {
|
||||
if (input.length <= 1) {
|
||||
return input;
|
||||
}
|
||||
const result: T[] = [];
|
||||
for (let i = 0, n = input.length; i < n; i++) {
|
||||
if (i) result.push(element);
|
||||
result.push(input[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
||||
* returns a falsey value, then returns false.
|
||||
|
||||
@@ -89,17 +89,14 @@ namespace ts.JsDoc {
|
||||
// Eg. const a: Array<string> | Array<number>; a.length
|
||||
// The property length will have two declarations of property length coming
|
||||
// from Array<T> - Array<string> and Array<number>
|
||||
const documentationComment: SymbolDisplayPart[] = [];
|
||||
const documentationComment: string[] = [];
|
||||
forEachUnique(declarations, declaration => {
|
||||
for (const { comment } of getCommentHavingNodes(declaration)) {
|
||||
if (comment === undefined) continue;
|
||||
if (documentationComment.length) {
|
||||
documentationComment.push(lineBreakPart());
|
||||
}
|
||||
documentationComment.push(textPart(comment));
|
||||
pushIfUnique(documentationComment, comment);
|
||||
}
|
||||
});
|
||||
return documentationComment;
|
||||
return intersperse(map(documentationComment, textPart), lineBreakPart());
|
||||
}
|
||||
|
||||
function getCommentHavingNodes(declaration: Declaration): readonly (JSDoc | JSDocTag)[] {
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.ts",
|
||||
"position": 746
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "property",
|
||||
"kindModifiers": "optional",
|
||||
"textSpan": {
|
||||
"start": 746,
|
||||
"length": 8
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "property",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "language",
|
||||
"kind": "propertyName"
|
||||
},
|
||||
{
|
||||
"text": "?",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
{
|
||||
"text": "A language id, like `typescript`.",
|
||||
"kind": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////export type DocumentFilter = {
|
||||
//// /** A language id, like `typescript`. */
|
||||
//// language: string;
|
||||
//// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
|
||||
//// scheme?: string;
|
||||
//// /** A glob pattern, like `*.{ts,js}`. */
|
||||
//// pattern?: string;
|
||||
////} | {
|
||||
//// /** A language id, like `typescript`. */
|
||||
//// language?: string;
|
||||
//// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
|
||||
//// scheme: string;
|
||||
//// /** A glob pattern, like `*.{ts,js}`. */
|
||||
//// pattern?: string;
|
||||
////} | {
|
||||
//// /** A language id, like `typescript`. */
|
||||
//// language?: string;
|
||||
//// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
|
||||
//// scheme?: string;
|
||||
//// /** A glob pattern, like `*.{ts,js}`. */
|
||||
//// pattern: string;
|
||||
////};
|
||||
////
|
||||
////declare let x: DocumentFilter;
|
||||
////x./**/language
|
||||
|
||||
verify.baselineQuickInfo();
|
||||
Reference in New Issue
Block a user