Skip to content

Commit fb5e8c6

Browse files
committed
Fix forEachChild's visit of JSDocTypedefTag
Also remove JSDocTypeLiteral.jsdocTypeTag, which made no sense since it was only useful when storing information for its parent `@typedef` tag.
1 parent 7aac67b commit fb5e8c6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/compiler/parser.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,10 @@ namespace ts {
438438
visitNode(cbNode, (<JSDocTypedefTag>node).typeExpression);
439439
}
440440
case SyntaxKind.JSDocTypeLiteral:
441-
for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags) {
442-
visitNode(cbNode, tag);
441+
if ((node as JSDocTypeLiteral).jsDocPropertyTags) {
442+
for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags) {
443+
visitNode(cbNode, tag);
444+
}
443445
}
444446
return;
445447
case SyntaxKind.PartiallyEmittedExpression:
@@ -6672,19 +6674,18 @@ namespace ts {
66726674
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
66736675
let child: JSDocTypeTag | JSDocPropertyTag | false;
66746676
let jsdocTypeLiteral: JSDocTypeLiteral;
6675-
let alreadyHasTypeTag = false;
6677+
let childTypeTag: JSDocTypeTag;
66766678
const start = scanner.getStartPos();
66776679
while (child = tryParse(() => parseChildParameterOrPropertyTag(PropertyLikeParse.Property))) {
66786680
if (!jsdocTypeLiteral) {
66796681
jsdocTypeLiteral = <JSDocTypeLiteral>createNode(SyntaxKind.JSDocTypeLiteral, start);
66806682
}
66816683
if (child.kind === SyntaxKind.JSDocTypeTag) {
6682-
if (alreadyHasTypeTag) {
6684+
if (childTypeTag) {
66836685
break;
66846686
}
66856687
else {
6686-
jsdocTypeLiteral.jsDocTypeTag = child;
6687-
alreadyHasTypeTag = true;
6688+
childTypeTag = child;
66886689
}
66896690
}
66906691
else {
@@ -6698,7 +6699,8 @@ namespace ts {
66986699
if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) {
66996700
jsdocTypeLiteral.isArrayType = true;
67006701
}
6701-
typedefTag.typeExpression = finishNode(jsdocTypeLiteral);
6702+
const useChildTypeTagAsType = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type);
6703+
typedefTag.typeExpression = useChildTypeTagAsType ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral);
67026704
}
67036705
}
67046706

src/compiler/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,6 @@ namespace ts {
22112211
export interface JSDocTypeLiteral extends JSDocType {
22122212
kind: SyntaxKind.JSDocTypeLiteral;
22132213
jsDocPropertyTags?: ReadonlyArray<JSDocPropertyLikeTag>;
2214-
jsDocTypeTag?: JSDocTypeTag;
22152214
/** If true, then this type literal represents an *array* of its type. */
22162215
isArrayType?: boolean;
22172216
}

0 commit comments

Comments
 (0)