From 503604c884bd0557c851b11b699ef98cdb65b93b Mon Sep 17 00:00:00 2001 From: Valerian Clerc Date: Tue, 11 Oct 2022 16:58:03 -0700 Subject: [PATCH] Overloads shouldn't gain @deprecated tags of other overloads in quick info (#50904) * Add test case to check for the propogation of @deprecation tag to multiple overloads * Implement filter to only include @deprecated tag in first signature after JSDoc comment --- src/services/symbolDisplay.ts | 3 ++- .../quickInfoJsDocTagsFunctionOverload06.ts | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts 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 new file mode 100644 index 0000000000000..987e649fed53e --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload06.ts @@ -0,0 +1,26 @@ +/// +// @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(["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"}]) +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