Skip to content

Commit f1ce0f5

Browse files
authored
Visit children of jsdoc type aliases in the binder (#45312)
* Visit children of jsdoc type aliases in the binder This sets up parent pointers. Fixes #45254 and almost certainly #45248, though I haven't figured out to repro the second case. * move incorrect parenthesis * manually set comment parent instead * Bind children of typedef where possible * add explanatory comment to binding
1 parent 1cbb0bd commit f1ce0f5

File tree

4 files changed

+124
-3
lines changed

4 files changed

+124
-3
lines changed

src/compiler/binder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,11 +1666,15 @@ namespace ts {
16661666
}
16671667

16681668
function bindJSDocTypeAlias(node: JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag) {
1669-
setParent(node.tagName, node);
1669+
bind(node.tagName);
16701670
if (node.kind !== SyntaxKind.JSDocEnumTag && node.fullName) {
1671+
// don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag
16711672
setParent(node.fullName, node);
16721673
setParentRecursive(node.fullName, /*incremental*/ false);
16731674
}
1675+
if (typeof node.comment !== "string") {
1676+
bindEach(node.comment);
1677+
}
16741678
}
16751679

16761680
function bindJSDocClassTag(node: JSDocClassTag) {

src/compiler/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ namespace ts {
530530
visitNode(cbNode, (node as JSDocTypedefTag).fullName) ||
531531
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined))
532532
: visitNode(cbNode, (node as JSDocTypedefTag).fullName) ||
533-
visitNode(cbNode, (node as JSDocTypedefTag).typeExpression)) ||
534-
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined));
533+
visitNode(cbNode, (node as JSDocTypedefTag).typeExpression) ||
534+
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined)));
535535
case SyntaxKind.JSDocCallbackTag:
536536
return visitNode(cbNode, (node as JSDocTag).tagName) ||
537537
visitNode(cbNode, (node as JSDocCallbackTag).fullName) ||
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
[
2+
{
3+
"marker": {
4+
"fileName": "/tests/cases/fourslash/quickInfoLink2.js",
5+
"position": 39,
6+
"name": ""
7+
},
8+
"quickInfo": {
9+
"kind": "type",
10+
"kindModifiers": "",
11+
"textSpan": {
12+
"start": 16,
13+
"length": 23
14+
},
15+
"displayParts": [
16+
{
17+
"text": "type",
18+
"kind": "keyword"
19+
},
20+
{
21+
"text": " ",
22+
"kind": "space"
23+
},
24+
{
25+
"text": "AdditionalWallabyConfig",
26+
"kind": "aliasName"
27+
},
28+
{
29+
"text": " ",
30+
"kind": "space"
31+
},
32+
{
33+
"text": "=",
34+
"kind": "operator"
35+
},
36+
{
37+
"text": " ",
38+
"kind": "space"
39+
},
40+
{
41+
"text": "{",
42+
"kind": "punctuation"
43+
},
44+
{
45+
"text": "\n",
46+
"kind": "lineBreak"
47+
},
48+
{
49+
"text": " ",
50+
"kind": "space"
51+
},
52+
{
53+
"text": "autoDetect",
54+
"kind": "propertyName"
55+
},
56+
{
57+
"text": ":",
58+
"kind": "punctuation"
59+
},
60+
{
61+
"text": " ",
62+
"kind": "space"
63+
},
64+
{
65+
"text": "boolean",
66+
"kind": "keyword"
67+
},
68+
{
69+
"text": ";",
70+
"kind": "punctuation"
71+
},
72+
{
73+
"text": "\n",
74+
"kind": "lineBreak"
75+
},
76+
{
77+
"text": "}",
78+
"kind": "punctuation"
79+
}
80+
],
81+
"documentation": [
82+
{
83+
"text": "Additional valid Wallaby config properties\nthat aren't defined in ",
84+
"kind": "text"
85+
},
86+
{
87+
"text": "{@link ",
88+
"kind": "link"
89+
},
90+
{
91+
"text": "IWallabyConfig ",
92+
"kind": "linkText"
93+
},
94+
{
95+
"text": "}",
96+
"kind": "link"
97+
},
98+
{
99+
"text": ".",
100+
"kind": "text"
101+
}
102+
]
103+
}
104+
}
105+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @checkJs: true
4+
// @Filename: quickInfoLink2.js
5+
//// /**
6+
//// * @typedef AdditionalWallabyConfig/**/ Additional valid Wallaby config properties
7+
//// * that aren't defined in {@link IWallabyConfig}.
8+
//// * @property {boolean} autoDetect
9+
//// */
10+
11+
verify.noErrors()
12+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)