fix(50117): Using @extends in JavaScript + JSDoc removes method documentations (#50256)

* fix(50117): show jsdoc from an inherited members

* show jsdoc from inherited members from class expressions
This commit is contained in:
Oleksandr T 2022-12-13 01:22:03 +02:00 committed by GitHub
parent d54f52e0de
commit 8f2a38f44b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 200 additions and 6 deletions

View File

@ -260,6 +260,7 @@ import {
isImportTypeNode,
isInterfaceDeclaration,
isJSDoc,
isJSDocAugmentsTag,
isJSDocFunctionType,
isJSDocLinkLike,
isJSDocMemberName,
@ -2763,7 +2764,7 @@ export function isExpressionNode(node: Node): boolean {
case SyntaxKind.MetaProperty:
return true;
case SyntaxKind.ExpressionWithTypeArguments:
return !isHeritageClause(node.parent);
return !isHeritageClause(node.parent) && !isJSDocAugmentsTag(node.parent);
case SyntaxKind.QualifiedName:
while (node.parent.kind === SyntaxKind.QualifiedName) {
node = node.parent;
@ -6117,11 +6118,18 @@ export interface ClassImplementingOrExtendingExpressionWithTypeArguments {
}
/** @internal */
export function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node: Node): ClassImplementingOrExtendingExpressionWithTypeArguments | undefined {
return isExpressionWithTypeArguments(node)
&& isHeritageClause(node.parent)
&& isClassLike(node.parent.parent)
? { class: node.parent.parent, isImplements: node.parent.token === SyntaxKind.ImplementsKeyword }
: undefined;
if (isExpressionWithTypeArguments(node)) {
if (isHeritageClause(node.parent) && isClassLike(node.parent.parent)) {
return { class: node.parent.parent, isImplements: node.parent.token === SyntaxKind.ImplementsKeyword };
}
if (isJSDocAugmentsTag(node.parent)) {
const host = getEffectiveJSDocHost(node.parent);
if (host && isClassLike(host)) {
return { class: host, isImplements: false };
}
}
}
return undefined;
}
/** @internal */

View File

@ -0,0 +1,73 @@
[
{
"marker": {
"fileName": "/a.js",
"position": 175,
"name": ""
},
"quickInfo": {
"kind": "method",
"kindModifiers": "",
"textSpan": {
"start": 169,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "B",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"documentation": [
{
"text": "Method documentation.",
"kind": "text"
}
]
}
}
]

View File

@ -0,0 +1,73 @@
[
{
"marker": {
"fileName": "/a.js",
"position": 183,
"name": ""
},
"quickInfo": {
"kind": "method",
"kindModifiers": "",
"textSpan": {
"start": 177,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "B",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"documentation": [
{
"text": "Method documentation.",
"kind": "text"
}
]
}
}
]

View File

@ -0,0 +1,20 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////** @template T */
////class A {
//// /** Method documentation. */
//// method() {}
////}
////
/////** @extends {A<number>} */
////class B extends A {
//// method() {}
////}
////
////const b = new B();
////b.method/**/;
verify.baselineQuickInfo();

View File

@ -0,0 +1,20 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////** @template T */
////class A {
//// /** Method documentation. */
//// method() {}
////}
////
/////** @extends {A<number>} */
////const B = class extends A {
//// method() {}
////}
////
////const b = new B();
////b.method/**/;
verify.baselineQuickInfo();