Skip to content

Commit e9e5fae

Browse files
committed
feat: Detect deprecated function overloads
1 parent 62489f7 commit e9e5fae

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/linter/ui5Types/SourceFileLinter.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ export default class SourceFileLinter {
246246
return deprecatedTag.text?.reduce((acc, text) => acc + text.text, "").split("\n\n")[0] ?? "";
247247
}
248248

249-
getDeprecationInfo(symbol: ts.Symbol | undefined): DeprecationInfo | null {
249+
getDeprecationInfo(symbol: ts.Symbol | undefined, signature?: ts.Signature): DeprecationInfo | null {
250250
if (symbol && this.isSymbolOfUi5Type(symbol)) {
251-
const jsdocTags = symbol.getJsDocTags(this.#checker);
251+
const jsdocTags = (signature ?? symbol).getJsDocTags(this.#checker);
252252
const deprecatedTag = jsdocTags.find((tag) => tag.name === "deprecated");
253253
if (deprecatedTag) {
254254
const deprecationInfo: DeprecationInfo = {
@@ -313,7 +313,9 @@ export default class SourceFileLinter {
313313
}
314314
}
315315

316-
const deprecationInfo = this.getDeprecationInfo(exprType.symbol);
316+
const signature = this.#checker.getResolvedSignature(node);
317+
const deprecationInfo = this.getDeprecationInfo(exprType.symbol, signature);
318+
317319
if (!deprecationInfo) {
318320
return;
319321
}
@@ -612,6 +614,20 @@ export default class SourceFileLinter {
612614
return; // Already analyzed in context of call expression
613615
}
614616

617+
const nodeType = this.#checker.getTypeAtLocation(node);
618+
const signatures = nodeType.getCallSignatures();
619+
if (signatures) {
620+
const allSignaturesDeprecated = signatures.every((signature) => {
621+
signature.getJsDocTags().some((tag) => {
622+
return tag.name === "deprecated";
623+
});
624+
});
625+
626+
if (!allSignaturesDeprecated) {
627+
return;
628+
}
629+
}
630+
615631
const deprecationInfo = this.getDeprecationInfoForAccess(node);
616632
if (deprecationInfo) {
617633
if (this.isSymbolOfJquerySapType(deprecationInfo.symbol)) {

0 commit comments

Comments
 (0)