Skip to content

Commit a05d851

Browse files
authoredNov 8, 2021
fix(45907): don't use static member name to inherit JSDocs from instance members (microsoft#46274)
1 parent 9713cc1 commit a05d851

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
 

‎src/services/services.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,10 +599,11 @@ namespace ts {
599599
}
600600

601601
function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration, cb: (symbol: Symbol) => T[] | undefined): T[] | undefined {
602+
if (hasStaticModifier(declaration)) return;
603+
602604
const classOrInterfaceDeclaration = declaration.parent?.kind === SyntaxKind.Constructor ? declaration.parent.parent : declaration.parent;
603-
if (!classOrInterfaceDeclaration) {
604-
return;
605-
}
605+
if (!classOrInterfaceDeclaration) return;
606+
606607
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
607608
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
608609
return symbol ? cb(symbol) : undefined;

‎tests/cases/fourslash/jsDocInheritDoc.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
//// * Foo#property1 documentation
1818
//// */
1919
//// property1: string;
20+
//// /**
21+
//// * Foo#property3 documentation
22+
//// */
23+
//// property3 = "instance prop";
2024
////}
2125
////interface Baz {
2226
//// /** Baz#property1 documentation */
@@ -43,6 +47,8 @@
4347
//// * @inheritDoc
4448
//// */
4549
//// property2: object;
50+
////
51+
//// static /*6*/property3 = "class prop";
4652
////}
4753
////const b = new Bar/*1*/(5);
4854
////b.method2/*2*/();
@@ -55,3 +61,4 @@ verify.quickInfoAt("2", "(method) Bar.method2(): void", "Foo#method2 documentati
5561
verify.quickInfoAt("3", "(method) Bar.method1(): void", undefined); // statics aren't actually inherited
5662
verify.quickInfoAt("4", "(property) Bar.property1: string", "Foo#property1 documentation"); // use inherited docs only
5763
verify.quickInfoAt("5", "(property) Bar.property2: object", "Baz#property2 documentation\nBar#property2"); // include local and inherited docs
64+
verify.quickInfoAt("6", "(property) Bar.property3: string", undefined);

0 commit comments

Comments
 (0)
Please sign in to comment.