Skip to content

Commit 53ec474

Browse files
committed
simplify implementation
1 parent 4d25f7f commit 53ec474

File tree

5 files changed

+213
-7
lines changed

5 files changed

+213
-7
lines changed

src/services/services.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,10 @@ namespace ts {
648648

649649
const isStaticMember = hasStaticModifier(declaration);
650650
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
651-
if (isStaticMember) {
652-
// For nodes like `class Foo extends Bar {}`, superTypeNode refers to an ExpressionWithTypeArguments with its expression being `Bar`.
653-
const baseClassSymbol = checker.getSymbolAtLocation(isExpressionWithTypeArguments(superTypeNode) && !superTypeNode.typeArguments?.length ? superTypeNode.expression : superTypeNode);
654-
const symbol = baseClassSymbol?.declarations?.[0] && checker.getPropertyOfType(checker.getTypeOfSymbolAtLocation(baseClassSymbol, baseClassSymbol.declarations[0]), declaration.symbol.name);
655-
return symbol ? cb(symbol) : undefined;
656-
}
657-
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
651+
const baseType = checker.getTypeAtLocation(superTypeNode);
652+
const symbol = isStaticMember
653+
? find(checker.getExportsOfModule(baseType.symbol), s => s.escapedName === declaration.symbol.name)
654+
: checker.getPropertyOfType(baseType, declaration.symbol.name);
658655
return symbol ? cb(symbol) : undefined;
659656
});
660657
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc2.ts",
5+
"position": 173,
6+
"name": "1"
7+
},
8+
"quickInfo": {
9+
"kind": "property",
10+
"kindModifiers": "",
11+
"textSpan": {
12+
"start": 173,
13+
"length": 4
14+
},
15+
"displayParts": [
16+
{
17+
"text": "(",
18+
"kind": "punctuation"
19+
},
20+
{
21+
"text": "property",
22+
"kind": "text"
23+
},
24+
{
25+
"text": ")",
26+
"kind": "punctuation"
27+
},
28+
{
29+
"text": " ",
30+
"kind": "space"
31+
},
32+
{
33+
"text": "SubClass",
34+
"kind": "className"
35+
},
36+
{
37+
"text": "<",
38+
"kind": "punctuation"
39+
},
40+
{
41+
"text": "T",
42+
"kind": "typeParameterName"
43+
},
44+
{
45+
"text": ">",
46+
"kind": "punctuation"
47+
},
48+
{
49+
"text": ".",
50+
"kind": "punctuation"
51+
},
52+
{
53+
"text": "prop",
54+
"kind": "propertyName"
55+
},
56+
{
57+
"text": ":",
58+
"kind": "punctuation"
59+
},
60+
{
61+
"text": " ",
62+
"kind": "space"
63+
},
64+
{
65+
"text": "T",
66+
"kind": "typeParameterName"
67+
}
68+
],
69+
"documentation": [
70+
{
71+
"text": "Base.prop",
72+
"kind": "text"
73+
}
74+
],
75+
"tags": [
76+
{
77+
"name": "inheritdoc",
78+
"text": [
79+
{
80+
"text": "SubClass.prop",
81+
"kind": "text"
82+
}
83+
]
84+
}
85+
]
86+
}
87+
}
88+
]
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc3.ts",
5+
"position": 237,
6+
"name": "1"
7+
},
8+
"quickInfo": {
9+
"kind": "property",
10+
"kindModifiers": "",
11+
"textSpan": {
12+
"start": 237,
13+
"length": 4
14+
},
15+
"displayParts": [
16+
{
17+
"text": "(",
18+
"kind": "punctuation"
19+
},
20+
{
21+
"text": "property",
22+
"kind": "text"
23+
},
24+
{
25+
"text": ")",
26+
"kind": "punctuation"
27+
},
28+
{
29+
"text": " ",
30+
"kind": "space"
31+
},
32+
{
33+
"text": "SubClass",
34+
"kind": "className"
35+
},
36+
{
37+
"text": ".",
38+
"kind": "punctuation"
39+
},
40+
{
41+
"text": "prop",
42+
"kind": "propertyName"
43+
},
44+
{
45+
"text": ":",
46+
"kind": "punctuation"
47+
},
48+
{
49+
"text": " ",
50+
"kind": "space"
51+
},
52+
{
53+
"text": "string",
54+
"kind": "keyword"
55+
}
56+
],
57+
"documentation": [
58+
{
59+
"text": "Base.prop",
60+
"kind": "text"
61+
}
62+
],
63+
"tags": [
64+
{
65+
"name": "inheritdoc",
66+
"text": [
67+
{
68+
"text": "SubClass.prop",
69+
"kind": "text"
70+
}
71+
]
72+
}
73+
]
74+
}
75+
}
76+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @noEmit: true
4+
// @allowJs: true
5+
6+
// @Filename: quickInfoInheritDoc2.ts
7+
////class Base<T> {
8+
//// /**
9+
//// * Base.prop
10+
//// */
11+
//// prop: T | undefined;
12+
////}
13+
////
14+
////class SubClass<T> extends Base<T> {
15+
//// /**
16+
//// * @inheritdoc
17+
//// * SubClass.prop
18+
//// */
19+
//// /*1*/prop: T | undefined;
20+
////}
21+
22+
verify.baselineQuickInfo();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @noEmit: true
4+
// @allowJs: true
5+
6+
// @Filename: quickInfoInheritDoc3.ts
7+
////function getBaseClass() {
8+
//// return class Base {
9+
//// /**
10+
//// * Base.prop
11+
//// */
12+
//// prop: string | undefined;
13+
//// }
14+
////}
15+
////class SubClass extends getBaseClass() {
16+
//// /**
17+
//// * @inheritdoc
18+
//// * SubClass.prop
19+
//// */
20+
//// /*1*/prop: string | undefined;
21+
////}
22+
23+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)