Skip to content

Commit

Permalink
fix(45907): don't use static member name to inherit JSDocs from insta…
Browse files Browse the repository at this point in the history
…nce members (microsoft#46274)
  • Loading branch information
a-tarasyuk authored Nov 8, 2021
1 parent 9713cc1 commit a05d851
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,11 @@ namespace ts {
}

function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration, cb: (symbol: Symbol) => T[] | undefined): T[] | undefined {
if (hasStaticModifier(declaration)) return;

const classOrInterfaceDeclaration = declaration.parent?.kind === SyntaxKind.Constructor ? declaration.parent.parent : declaration.parent;
if (!classOrInterfaceDeclaration) {
return;
}
if (!classOrInterfaceDeclaration) return;

return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
return symbol ? cb(symbol) : undefined;
Expand Down
7 changes: 7 additions & 0 deletions tests/cases/fourslash/jsDocInheritDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
//// * Foo#property1 documentation
//// */
//// property1: string;
//// /**
//// * Foo#property3 documentation
//// */
//// property3 = "instance prop";
////}
////interface Baz {
//// /** Baz#property1 documentation */
Expand All @@ -43,6 +47,8 @@
//// * @inheritDoc
//// */
//// property2: object;
////
//// static /*6*/property3 = "class prop";
////}
////const b = new Bar/*1*/(5);
////b.method2/*2*/();
Expand All @@ -55,3 +61,4 @@ verify.quickInfoAt("2", "(method) Bar.method2(): void", "Foo#method2 documentati
verify.quickInfoAt("3", "(method) Bar.method1(): void", undefined); // statics aren't actually inherited
verify.quickInfoAt("4", "(property) Bar.property1: string", "Foo#property1 documentation"); // use inherited docs only
verify.quickInfoAt("5", "(property) Bar.property2: object", "Baz#property2 documentation\nBar#property2"); // include local and inherited docs
verify.quickInfoAt("6", "(property) Bar.property3: string", undefined);

0 comments on commit a05d851

Please sign in to comment.