Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(45907): Quick info uses JSDoc for inherited instance property with static property of same name #46274

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);