From 7d2233a00e5c6d794c1de32c03802e8ccce1914c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 1 May 2018 15:44:10 -0700 Subject: [PATCH] Rename typeExpression to type (for some jsdoc) (maybe I'll rename more later) --- src/compiler/checker.ts | 7 +++---- src/compiler/parser.ts | 16 ++++++++-------- src/compiler/types.ts | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2ca479492b5..2b2e3e00cd0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5357,9 +5357,8 @@ namespace ts { const declaration = find(symbol.declarations, d => isJSDocTypeAlias(d) || d.kind === SyntaxKind.TypeAliasDeclaration); - const typeNode = isJSDocTypedefTag(declaration) ? declaration.typeExpression : isJSDocCallbackTag(declaration) ? declaration.signature : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. - let type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; + let type = declaration.type ? getTypeFromTypeNode(declaration.type) : unknownType; if (popTypeResolution()) { const typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -22147,7 +22146,7 @@ namespace ts { } function checkJSDocTypedefTag(node: JSDocTypedefTag) { - if (!node.typeExpression) { + if (!node.type) { // If the node had `@property` tags, `typeExpression` would have been set to the first property tag. error(node.name, Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); } @@ -22155,7 +22154,7 @@ namespace ts { if (node.name) { checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0); } - checkSourceElement(node.typeExpression); + checkSourceElement(node.type); } function checkJSDocParameterTag(node: JSDocParameterTag) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index dd197f7ab26..d516c3898ba 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -480,18 +480,18 @@ namespace ts { case SyntaxKind.JSDocTemplateTag: return visitNodes(cbNode, cbNodes, (node).typeParameters); case SyntaxKind.JSDocTypedefTag: - if ((node as JSDocTypedefTag).typeExpression && - (node as JSDocTypedefTag).typeExpression.kind === SyntaxKind.JSDocTypeExpression) { - return visitNode(cbNode, (node).typeExpression) || + if ((node as JSDocTypedefTag).type && + (node as JSDocTypedefTag).type.kind === SyntaxKind.JSDocTypeExpression) { + return visitNode(cbNode, (node).type) || visitNode(cbNode, (node).fullName); } else { return visitNode(cbNode, (node).fullName) || - visitNode(cbNode, (node).typeExpression); + visitNode(cbNode, (node).type); } case SyntaxKind.JSDocCallbackTag: return visitNode(cbNode, (node as JSDocCallbackTag).fullName) || - visitNode(cbNode, (node as JSDocCallbackTag).signature); + visitNode(cbNode, (node as JSDocCallbackTag).type); case SyntaxKind.JSDocSignature: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || @@ -6737,7 +6737,7 @@ namespace ts { // Debug.assert(child.kind !== SyntaxKind.JSDocTypeTag); jsdocSignature.parameters = append(jsdocSignature.parameters as MutableNodeArray, child); } - callbackTag.signature = finishNode(jsdocSignature); + callbackTag.type = finishNode(jsdocSignature); return finishNode(callbackTag); } @@ -6764,7 +6764,7 @@ namespace ts { typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); skipWhitespace(); - typedefTag.typeExpression = typeExpression; + typedefTag.type = typeExpression; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { let child: JSDocTypeTag | JSDocPropertyTag | false; let jsdocTypeLiteral: JSDocTypeLiteral; @@ -6790,7 +6790,7 @@ namespace ts { if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + typedefTag.type = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0458dc36420..b0939668d91 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2384,7 +2384,7 @@ namespace ts { kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; - typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; + type?: JSDocTypeExpression | JSDocTypeLiteral; } export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { @@ -2392,7 +2392,7 @@ namespace ts { kind: SyntaxKind.JSDocCallbackTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; // TODO: Not sure whether this rigamarole is needed for callback...but probably! - signature: JSDocSignature; + type: JSDocSignature; } // TODO: Could just try to reuse JSDocTypeLiteral