From 4abad0f17e5887c93794f8395c8b7bd9dadf637f Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 11 May 2022 09:58:15 +0300 Subject: [PATCH 1/2] fix(49058): skip unresolved base members --- src/services/services.ts | 2 +- .../reference/quickInfoInheritDoc4.baseline | 73 +++++++++++++++++++ .../reference/quickInfoInheritDoc5.baseline | 73 +++++++++++++++++++ .../reference/quickInfoInheritDoc6.baseline | 73 +++++++++++++++++++ tests/cases/fourslash/quickInfoInheritDoc4.ts | 15 ++++ tests/cases/fourslash/quickInfoInheritDoc5.ts | 18 +++++ tests/cases/fourslash/quickInfoInheritDoc6.ts | 16 ++++ 7 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/quickInfoInheritDoc4.baseline create mode 100644 tests/baselines/reference/quickInfoInheritDoc5.baseline create mode 100644 tests/baselines/reference/quickInfoInheritDoc6.baseline create mode 100644 tests/cases/fourslash/quickInfoInheritDoc4.ts create mode 100644 tests/cases/fourslash/quickInfoInheritDoc5.ts create mode 100644 tests/cases/fourslash/quickInfoInheritDoc6.ts diff --git a/src/services/services.ts b/src/services/services.ts index afb6a10869175..6b5940df14d93 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -650,7 +650,7 @@ namespace ts { return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => { const baseType = checker.getTypeAtLocation(superTypeNode); const symbol = isStaticMember - ? find(checker.getExportsOfModule(baseType.symbol), s => s.escapedName === declaration.symbol.name) + ? baseType.symbol && find(checker.getExportsOfModule(baseType.symbol), s => s.escapedName === declaration.symbol.name) : checker.getPropertyOfType(baseType, declaration.symbol.name); return symbol ? cb(symbol) : undefined; }); diff --git a/tests/baselines/reference/quickInfoInheritDoc4.baseline b/tests/baselines/reference/quickInfoInheritDoc4.baseline new file mode 100644 index 0000000000000..76e64f647d066 --- /dev/null +++ b/tests/baselines/reference/quickInfoInheritDoc4.baseline @@ -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" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickInfoInheritDoc5.baseline b/tests/baselines/reference/quickInfoInheritDoc5.baseline new file mode 100644 index 0000000000000..09bc74d1e86a3 --- /dev/null +++ b/tests/baselines/reference/quickInfoInheritDoc5.baseline @@ -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" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickInfoInheritDoc6.baseline b/tests/baselines/reference/quickInfoInheritDoc6.baseline new file mode 100644 index 0000000000000..c23fd104f01ff --- /dev/null +++ b/tests/baselines/reference/quickInfoInheritDoc6.baseline @@ -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" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoInheritDoc4.ts b/tests/cases/fourslash/quickInfoInheritDoc4.ts new file mode 100644 index 0000000000000..70287075429b7 --- /dev/null +++ b/tests/cases/fourslash/quickInfoInheritDoc4.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: quickInfoInheritDoc4.ts +////var A: any; +//// +////class B extends A { +//// /** +//// * @inheritdoc +//// */ +//// static /**/value() { +//// return undefined; +//// } +////} + +verify.baselineQuickInfo(); diff --git a/tests/cases/fourslash/quickInfoInheritDoc5.ts b/tests/cases/fourslash/quickInfoInheritDoc5.ts new file mode 100644 index 0000000000000..9790a74712dae --- /dev/null +++ b/tests/cases/fourslash/quickInfoInheritDoc5.ts @@ -0,0 +1,18 @@ +/// + +// @allowJs: true +// @checkJs: true + +// @Filename: quickInfoInheritDoc5.js +////function A() {} +//// +////class B extends A { +//// /** +//// * @inheritdoc +//// */ +//// static /**/value() { +//// return undefined; +//// } +////} + +verify.baselineQuickInfo(); diff --git a/tests/cases/fourslash/quickInfoInheritDoc6.ts b/tests/cases/fourslash/quickInfoInheritDoc6.ts new file mode 100644 index 0000000000000..eb7deca9523b6 --- /dev/null +++ b/tests/cases/fourslash/quickInfoInheritDoc6.ts @@ -0,0 +1,16 @@ +/// + +// @allowJs: true +// @checkJs: true + +// @Filename: quickInfoInheritDoc6.js +////class B extends UNRESOLVED_VALUE_DEFINITELY_DOES_NOT_EXIST { +//// /** +//// * @inheritdoc +//// */ +//// static /**/value() { +//// return undefined; +//// } +////} + +verify.baselineQuickInfo(); From bcf46fd0c92cfb1d344cf1083fb4498a629f0b1b Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Mon, 16 May 2022 19:35:03 +0300 Subject: [PATCH 2/2] use getTypeOfSymbol instead of getExportsOfModule --- src/services/services.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 6b5940df14d93..c46a6a3f40976 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -649,9 +649,8 @@ namespace ts { const isStaticMember = hasStaticModifier(declaration); return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => { const baseType = checker.getTypeAtLocation(superTypeNode); - const symbol = isStaticMember - ? baseType.symbol && 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; }); }