Skip to content

Commit

Permalink
feat: Detect deprecated function overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Sep 26, 2024
1 parent 62489f7 commit e9e5fae
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/linter/ui5Types/SourceFileLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit e9e5fae

Please sign in to comment.