From e9e5fae4a5d9b341cb4cd0f6212e1874cf47053b Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Wed, 4 Sep 2024 17:32:27 +0200 Subject: [PATCH] feat: Detect deprecated function overloads --- src/linter/ui5Types/SourceFileLinter.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/linter/ui5Types/SourceFileLinter.ts b/src/linter/ui5Types/SourceFileLinter.ts index 8055663f..bf133469 100644 --- a/src/linter/ui5Types/SourceFileLinter.ts +++ b/src/linter/ui5Types/SourceFileLinter.ts @@ -246,9 +246,9 @@ export default class SourceFileLinter { return deprecatedTag.text?.reduce((acc, text) => acc + text.text, "").split("\n\n")[0] ?? ""; } - getDeprecationInfo(symbol: ts.Symbol | undefined): DeprecationInfo | null { + getDeprecationInfo(symbol: ts.Symbol | undefined, signature?: ts.Signature): DeprecationInfo | null { if (symbol && this.isSymbolOfUi5Type(symbol)) { - const jsdocTags = symbol.getJsDocTags(this.#checker); + const jsdocTags = (signature ?? symbol).getJsDocTags(this.#checker); const deprecatedTag = jsdocTags.find((tag) => tag.name === "deprecated"); if (deprecatedTag) { const deprecationInfo: DeprecationInfo = { @@ -313,7 +313,9 @@ export default class SourceFileLinter { } } - const deprecationInfo = this.getDeprecationInfo(exprType.symbol); + const signature = this.#checker.getResolvedSignature(node); + const deprecationInfo = this.getDeprecationInfo(exprType.symbol, signature); + if (!deprecationInfo) { return; } @@ -612,6 +614,20 @@ export default class SourceFileLinter { return; // Already analyzed in context of call expression } + const nodeType = this.#checker.getTypeAtLocation(node); + const signatures = nodeType.getCallSignatures(); + if (signatures) { + const allSignaturesDeprecated = signatures.every((signature) => { + signature.getJsDocTags().some((tag) => { + return tag.name === "deprecated"; + }); + }); + + if (!allSignaturesDeprecated) { + return; + } + } + const deprecationInfo = this.getDeprecationInfoForAccess(node); if (deprecationInfo) { if (this.isSymbolOfJquerySapType(deprecationInfo.symbol)) {