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
This commit is contained in:
Oleksandr T
2022-05-16 14:29:40 -07:00
committed by GitHub
parent 95731f0397
commit 0df9462a96
7 changed files with 270 additions and 3 deletions
+2 -3
View File
@@ -649,9 +649,8 @@ namespace ts {
const isStaticMember = hasStaticModifier(declaration);
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
const baseType = checker.getTypeAtLocation(superTypeNode);
const symbol = isStaticMember
? find(checker.getExportsOfModule(baseType.symbol), s => s.escapedName === declaration.symbol.name)
: checker.getPropertyOfType(baseType, declaration.symbol.name);
const type = isStaticMember && baseType.symbol ? checker.getTypeOfSymbol(baseType.symbol) : baseType;
const symbol = checker.getPropertyOfType(type, declaration.symbol.name);
return symbol ? cb(symbol) : undefined;
});
}
@@ -0,0 +1,73 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc4.ts",
"position": 79,
"name": ""
},
"quickInfo": {
"kind": "method",
"kindModifiers": "static",
"textSpan": {
"start": 79,
"length": 5
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "B",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "value",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"documentation": [],
"tags": [
{
"name": "inheritdoc"
}
]
}
}
]
@@ -0,0 +1,73 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc5.js",
"position": 83,
"name": ""
},
"quickInfo": {
"kind": "method",
"kindModifiers": "static",
"textSpan": {
"start": 83,
"length": 5
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "B",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "value",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"documentation": [],
"tags": [
{
"name": "inheritdoc"
}
]
}
}
]
@@ -0,0 +1,73 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoInheritDoc6.js",
"position": 107,
"name": ""
},
"quickInfo": {
"kind": "method",
"kindModifiers": "static",
"textSpan": {
"start": 107,
"length": 5
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "B",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "value",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"documentation": [],
"tags": [
{
"name": "inheritdoc"
}
]
}
}
]
@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @Filename: quickInfoInheritDoc4.ts
////var A: any;
////
////class B extends A {
//// /**
//// * @inheritdoc
//// */
//// static /**/value() {
//// return undefined;
//// }
////}
verify.baselineQuickInfo();
@@ -0,0 +1,18 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: quickInfoInheritDoc5.js
////function A() {}
////
////class B extends A {
//// /**
//// * @inheritdoc
//// */
//// static /**/value() {
//// return undefined;
//// }
////}
verify.baselineQuickInfo();
@@ -0,0 +1,16 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: quickInfoInheritDoc6.js
////class B extends UNRESOLVED_VALUE_DEFINITELY_DOES_NOT_EXIST {
//// /**
//// * @inheritdoc
//// */
//// static /**/value() {
//// return undefined;
//// }
////}
verify.baselineQuickInfo();