mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-13 04:57:55 -06:00
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:
parent
d54f52e0de
commit
8f2a38f44b
@ -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 */
|
||||
|
||||
73
tests/baselines/reference/jsdocOnInheritedMembers1.baseline
Normal file
73
tests/baselines/reference/jsdocOnInheritedMembers1.baseline
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
73
tests/baselines/reference/jsdocOnInheritedMembers2.baseline
Normal file
73
tests/baselines/reference/jsdocOnInheritedMembers2.baseline
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
20
tests/cases/fourslash/jsdocOnInheritedMembers1.ts
Normal file
20
tests/cases/fourslash/jsdocOnInheritedMembers1.ts
Normal 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();
|
||||
20
tests/cases/fourslash/jsdocOnInheritedMembers2.ts
Normal file
20
tests/cases/fourslash/jsdocOnInheritedMembers2.ts
Normal 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();
|
||||
Loading…
x
Reference in New Issue
Block a user