Skip to content

Commit eb09afb

Browse files
committed
fix(55650): show quick info in JSDoc @implements tag
1 parent d027e96 commit eb09afb

File tree

3 files changed

+141
-2
lines changed

3 files changed

+141
-2
lines changed

src/compiler/utilities.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ import {
282282
isJSDoc,
283283
isJSDocAugmentsTag,
284284
isJSDocFunctionType,
285+
isJSDocImplementsTag,
285286
isJSDocLinkLike,
286287
isJSDocMemberName,
287288
isJSDocNameReference,
@@ -2452,7 +2453,7 @@ export function isPartOfTypeNode(node: Node): boolean {
24522453
case SyntaxKind.VoidKeyword:
24532454
return node.parent.kind !== SyntaxKind.VoidExpression;
24542455
case SyntaxKind.ExpressionWithTypeArguments:
2455-
return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
2456+
return isPartOfTypeExpressionWithTypeArguments(node);
24562457
case SyntaxKind.TypeParameter:
24572458
return node.parent.kind === SyntaxKind.MappedType || node.parent.kind === SyntaxKind.InferType;
24582459

@@ -2491,7 +2492,7 @@ export function isPartOfTypeNode(node: Node): boolean {
24912492
}
24922493
switch (parent.kind) {
24932494
case SyntaxKind.ExpressionWithTypeArguments:
2494-
return isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
2495+
return isPartOfTypeExpressionWithTypeArguments(parent);
24952496
case SyntaxKind.TypeParameter:
24962497
return node === (parent as TypeParameterDeclaration).constraint;
24972498
case SyntaxKind.JSDocTemplateTag:
@@ -2527,6 +2528,12 @@ export function isPartOfTypeNode(node: Node): boolean {
25272528
return false;
25282529
}
25292530

2531+
function isPartOfTypeExpressionWithTypeArguments(node: Node) {
2532+
return isJSDocImplementsTag(node.parent)
2533+
|| isJSDocAugmentsTag(node.parent)
2534+
|| isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
2535+
}
2536+
25302537
/** @internal */
25312538
export function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean {
25322539
while (node) {
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// === QuickInfo ===
2+
=== /b.js ===
3+
// import * as _a from "./a.js";
4+
// /**
5+
// * @implements {_a.Foo}
6+
// ^^^
7+
// | ----------------------------------------------------------------------
8+
// | type Foo = {
9+
// | getName: _a.Bar;
10+
// | }
11+
// | ----------------------------------------------------------------------
12+
// */
13+
// class Foo { }
14+
15+
[
16+
{
17+
"marker": {
18+
"fileName": "/b.js",
19+
"position": 56,
20+
"name": "2"
21+
},
22+
"item": {
23+
"kind": "type",
24+
"kindModifiers": "",
25+
"textSpan": {
26+
"start": 53,
27+
"length": 3
28+
},
29+
"displayParts": [
30+
{
31+
"text": "type",
32+
"kind": "keyword"
33+
},
34+
{
35+
"text": " ",
36+
"kind": "space"
37+
},
38+
{
39+
"text": "Foo",
40+
"kind": "aliasName"
41+
},
42+
{
43+
"text": " ",
44+
"kind": "space"
45+
},
46+
{
47+
"text": "=",
48+
"kind": "operator"
49+
},
50+
{
51+
"text": " ",
52+
"kind": "space"
53+
},
54+
{
55+
"text": "{",
56+
"kind": "punctuation"
57+
},
58+
{
59+
"text": "\n",
60+
"kind": "lineBreak"
61+
},
62+
{
63+
"text": " ",
64+
"kind": "space"
65+
},
66+
{
67+
"text": "getName",
68+
"kind": "propertyName"
69+
},
70+
{
71+
"text": ":",
72+
"kind": "punctuation"
73+
},
74+
{
75+
"text": " ",
76+
"kind": "space"
77+
},
78+
{
79+
"text": "_a",
80+
"kind": "aliasName"
81+
},
82+
{
83+
"text": ".",
84+
"kind": "punctuation"
85+
},
86+
{
87+
"text": "Bar",
88+
"kind": "aliasName"
89+
},
90+
{
91+
"text": ";",
92+
"kind": "punctuation"
93+
},
94+
{
95+
"text": "\n",
96+
"kind": "lineBreak"
97+
},
98+
{
99+
"text": "}",
100+
"kind": "punctuation"
101+
}
102+
],
103+
"documentation": []
104+
}
105+
}
106+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
// @filename: /a.js
6+
/////**
7+
//// * @callback Bar
8+
//// * @param {string} name
9+
//// * @returns {string}
10+
//// */
11+
////
12+
/////**
13+
//// * @typedef Foo
14+
//// * @property {Bar} getName
15+
//// */
16+
////export const foo = 1;
17+
18+
// @filename: /b.js
19+
////import * as _a from "./a.js";
20+
/////**
21+
//// * @implements {_a.Foo/*2*/}
22+
//// */
23+
////class Foo { }
24+
25+
goTo.file("/b.js")
26+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)