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
This commit is contained in:
Nathan Shively-Sanders
2021-08-04 07:05:11 -07:00
committed by GitHub
parent 1cbb0bd4d3
commit f1ce0f5528
4 changed files with 124 additions and 3 deletions

View File

@@ -1666,11 +1666,15 @@ namespace ts {
}
function bindJSDocTypeAlias(node: JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag) {
setParent(node.tagName, node);
bind(node.tagName);
if (node.kind !== SyntaxKind.JSDocEnumTag && node.fullName) {
// don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag
setParent(node.fullName, node);
setParentRecursive(node.fullName, /*incremental*/ false);
}
if (typeof node.comment !== "string") {
bindEach(node.comment);
}
}
function bindJSDocClassTag(node: JSDocClassTag) {

View File

@@ -530,8 +530,8 @@ namespace ts {
visitNode(cbNode, (node as JSDocTypedefTag).fullName) ||
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined))
: visitNode(cbNode, (node as JSDocTypedefTag).fullName) ||
visitNode(cbNode, (node as JSDocTypedefTag).typeExpression)) ||
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined));
visitNode(cbNode, (node as JSDocTypedefTag).typeExpression) ||
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined)));
case SyntaxKind.JSDocCallbackTag:
return visitNode(cbNode, (node as JSDocTag).tagName) ||
visitNode(cbNode, (node as JSDocCallbackTag).fullName) ||