Skip to content

Commit 0df9462

Browse files
authored
fix(49058): Language service crashes for static member in class with unresolved base members (#49059)
* fix(49058): skip unresolved base members * use getTypeOfSymbol instead of getExportsOfModule
1 parent 95731f0 commit 0df9462

File tree

7 files changed

+270
-3
lines changed

7 files changed

+270
-3
lines changed

src/services/services.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,8 @@ namespace ts {
649649
const isStaticMember = hasStaticModifier(declaration);
650650
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
651651
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);
652+
const type = isStaticMember && baseType.symbol ? checker.getTypeOfSymbol(baseType.symbol) : baseType;
653+
const symbol = checker.getPropertyOfType(type, declaration.symbol.name);
655654
return symbol ? cb(symbol) : undefined;
656655
});
657656
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc4.ts",
5+
"position": 79,
6+
"name": ""
7+
},
8+
"quickInfo": {
9+
"kind": "method",
10+
"kindModifiers": "static",
11+
"textSpan": {
12+
"start": 79,
13+
"length": 5
14+
},
15+
"displayParts": [
16+
{
17+
"text": "(",
18+
"kind": "punctuation"
19+
},
20+
{
21+
"text": "method",
22+
"kind": "text"
23+
},
24+
{
25+
"text": ")",
26+
"kind": "punctuation"
27+
},
28+
{
29+
"text": " ",
30+
"kind": "space"
31+
},
32+
{
33+
"text": "B",
34+
"kind": "className"
35+
},
36+
{
37+
"text": ".",
38+
"kind": "punctuation"
39+
},
40+
{
41+
"text": "value",
42+
"kind": "methodName"
43+
},
44+
{
45+
"text": "(",
46+
"kind": "punctuation"
47+
},
48+
{
49+
"text": ")",
50+
"kind": "punctuation"
51+
},
52+
{
53+
"text": ":",
54+
"kind": "punctuation"
55+
},
56+
{
57+
"text": " ",
58+
"kind": "space"
59+
},
60+
{
61+
"text": "any",
62+
"kind": "keyword"
63+
}
64+
],
65+
"documentation": [],
66+
"tags": [
67+
{
68+
"name": "inheritdoc"
69+
}
70+
]
71+
}
72+
}
73+
]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc5.js",
5+
"position": 83,
6+
"name": ""
7+
},
8+
"quickInfo": {
9+
"kind": "method",
10+
"kindModifiers": "static",
11+
"textSpan": {
12+
"start": 83,
13+
"length": 5
14+
},
15+
"displayParts": [
16+
{
17+
"text": "(",
18+
"kind": "punctuation"
19+
},
20+
{
21+
"text": "method",
22+
"kind": "text"
23+
},
24+
{
25+
"text": ")",
26+
"kind": "punctuation"
27+
},
28+
{
29+
"text": " ",
30+
"kind": "space"
31+
},
32+
{
33+
"text": "B",
34+
"kind": "className"
35+
},
36+
{
37+
"text": ".",
38+
"kind": "punctuation"
39+
},
40+
{
41+
"text": "value",
42+
"kind": "methodName"
43+
},
44+
{
45+
"text": "(",
46+
"kind": "punctuation"
47+
},
48+
{
49+
"text": ")",
50+
"kind": "punctuation"
51+
},
52+
{
53+
"text": ":",
54+
"kind": "punctuation"
55+
},
56+
{
57+
"text": " ",
58+
"kind": "space"
59+
},
60+
{
61+
"text": "any",
62+
"kind": "keyword"
63+
}
64+
],
65+
"documentation": [],
66+
"tags": [
67+
{
68+
"name": "inheritdoc"
69+
}
70+
]
71+
}
72+
}
73+
]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc6.js",
5+
"position": 107,
6+
"name": ""
7+
},
8+
"quickInfo": {
9+
"kind": "method",
10+
"kindModifiers": "static",
11+
"textSpan": {
12+
"start": 107,
13+
"length": 5
14+
},
15+
"displayParts": [
16+
{
17+
"text": "(",
18+
"kind": "punctuation"
19+
},
20+
{
21+
"text": "method",
22+
"kind": "text"
23+
},
24+
{
25+
"text": ")",
26+
"kind": "punctuation"
27+
},
28+
{
29+
"text": " ",
30+
"kind": "space"
31+
},
32+
{
33+
"text": "B",
34+
"kind": "className"
35+
},
36+
{
37+
"text": ".",
38+
"kind": "punctuation"
39+
},
40+
{
41+
"text": "value",
42+
"kind": "methodName"
43+
},
44+
{
45+
"text": "(",
46+
"kind": "punctuation"
47+
},
48+
{
49+
"text": ")",
50+
"kind": "punctuation"
51+
},
52+
{
53+
"text": ":",
54+
"kind": "punctuation"
55+
},
56+
{
57+
"text": " ",
58+
"kind": "space"
59+
},
60+
{
61+
"text": "any",
62+
"kind": "keyword"
63+
}
64+
],
65+
"documentation": [],
66+
"tags": [
67+
{
68+
"name": "inheritdoc"
69+
}
70+
]
71+
}
72+
}
73+
]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: quickInfoInheritDoc4.ts
4+
////var A: any;
5+
////
6+
////class B extends A {
7+
//// /**
8+
//// * @inheritdoc
9+
//// */
10+
//// static /**/value() {
11+
//// return undefined;
12+
//// }
13+
////}
14+
15+
verify.baselineQuickInfo();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
6+
// @Filename: quickInfoInheritDoc5.js
7+
////function A() {}
8+
////
9+
////class B extends A {
10+
//// /**
11+
//// * @inheritdoc
12+
//// */
13+
//// static /**/value() {
14+
//// return undefined;
15+
//// }
16+
////}
17+
18+
verify.baselineQuickInfo();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
6+
// @Filename: quickInfoInheritDoc6.js
7+
////class B extends UNRESOLVED_VALUE_DEFINITELY_DOES_NOT_EXIST {
8+
//// /**
9+
//// * @inheritdoc
10+
//// */
11+
//// static /**/value() {
12+
//// return undefined;
13+
//// }
14+
////}
15+
16+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)