From 57dff9e8e86e4641606805d93f98e7595a6e5423 Mon Sep 17 00:00:00 2001 From: Valerian Clerc Date: Mon, 19 Sep 2022 15:50:14 -0700 Subject: [PATCH 1/2] Add test case to check for the propogation of @deprecation tag to multiple overloads --- .../quickInfoJsDocTagsFunctionOverload06.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts diff --git a/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts b/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts new file mode 100644 index 0000000000000..7a2e162c72cf2 --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts @@ -0,0 +1,23 @@ +/// +// @target: esnext + +// @Filename: /a.ts +/////** +//// * A function that gets the length of an array. +//// * @param testParam +//// * @deprecated Use the new method instead. +//// */ +////export function getArrayLength(arr: string[]): number; +////export function getArrayLength(arr: boolean[]): number; + +// @Filename: /b.ts +////import { getArrayLength } from "/a"; +/////*1*/getArrayLength(["1"]); +/////*2*/getArrayLength([true]); + + +goTo.file("/b.ts"); +goTo.marker("1") +verify.quickInfoIs("(alias) getArrayLength(arr: string[]): number (+1 overload)\nimport getArrayLength", "A function that gets the length of an array.", [{name: "param", text: "testParam"}, {name: "deprecated", text: "Use the new method instead."}]) +goTo.marker("2") +verify.quickInfoIs("(alias) getArrayLength(arr: boolean[]): number (+1 overload)\nimport getArrayLength", "A function that gets the length of an array.", [{name: "param", text: "testParam"}]) \ No newline at end of file From 741996e0f57c3bca0829cf5420b64ea21331f894 Mon Sep 17 00:00:00 2001 From: Valerian Clerc Date: Thu, 22 Sep 2022 18:57:26 +0000 Subject: [PATCH 2/2] Implement filter to only include @deprecated tag in first signature after JSDoc comment --- src/services/symbolDisplay.ts | 3 ++- .../fourslash/quickInfoJsDocTagsFunctionOverload06.ts | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 87b5e16f29db9..6ba2243b750dd 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -725,8 +725,9 @@ namespace ts.SymbolDisplay { if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) { documentation = allSignatures[0].getDocumentationComment(typeChecker); - tags = allSignatures[0].getJsDocTags(); + tags = allSignatures[0].getJsDocTags().filter(tag => tag.name !== "deprecated"); // should only include @deprecated JSDoc tag on the first overload (#49368) } + } function writeTypeParametersOfSymbol(symbol: Symbol, enclosingDeclaration: Node | undefined) { diff --git a/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts b/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts index 7a2e162c72cf2..987e649fed53e 100644 --- a/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts +++ b/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts @@ -12,12 +12,15 @@ // @Filename: /b.ts ////import { getArrayLength } from "/a"; -/////*1*/getArrayLength(["1"]); +/////*1*/getArrayLength(["hello"]); /////*2*/getArrayLength([true]); +/////*3*/getArrayLength(["hello"]); goTo.file("/b.ts"); goTo.marker("1") verify.quickInfoIs("(alias) getArrayLength(arr: string[]): number (+1 overload)\nimport getArrayLength", "A function that gets the length of an array.", [{name: "param", text: "testParam"}, {name: "deprecated", text: "Use the new method instead."}]) goTo.marker("2") -verify.quickInfoIs("(alias) getArrayLength(arr: boolean[]): number (+1 overload)\nimport getArrayLength", "A function that gets the length of an array.", [{name: "param", text: "testParam"}]) \ No newline at end of file +verify.quickInfoIs("(alias) getArrayLength(arr: boolean[]): number (+1 overload)\nimport getArrayLength", "A function that gets the length of an array.", [{name: "param", text: "testParam"}]) +goTo.marker("3") +verify.quickInfoIs("(alias) getArrayLength(arr: string[]): number (+1 overload)\nimport getArrayLength", "A function that gets the length of an array.", [{name: "param", text: "testParam"}, {name: "deprecated", text: "Use the new method instead."}]) \ No newline at end of file