Skip to content

Commit f41a96b

Browse files
committed
Rename the rest of typeExpressions
Turns out there is a constraint in services such that they all need to be named the same.
1 parent 7d2233a commit f41a96b

File tree

8 files changed

+39
-39
lines changed

8 files changed

+39
-39
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ namespace ts {
22142214
// falls through
22152215
case SyntaxKind.JSDocPropertyTag:
22162216
const propTag = node as JSDocPropertyLikeTag;
2217-
const flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType ?
2217+
const flags = propTag.isBracketed || propTag.type && propTag.type.type.kind === SyntaxKind.JSDocOptionalType ?
22182218
SymbolFlags.Property | SymbolFlags.Optional :
22192219
SymbolFlags.Property;
22202220
return declareSymbolAndAddToSymbolTable(propTag, flags, SymbolFlags.PropertyExcludes);

src/compiler/checker.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4708,8 +4708,8 @@ namespace ts {
47084708
if (declaration.kind === SyntaxKind.ExportAssignment) {
47094709
return links.type = checkExpression((<ExportAssignment>declaration).expression);
47104710
}
4711-
if (isInJavaScriptFile(declaration) && isJSDocPropertyLikeTag(declaration) && declaration.typeExpression) {
4712-
return links.type = getTypeFromTypeNode(declaration.typeExpression.type);
4711+
if (isInJavaScriptFile(declaration) && isJSDocPropertyLikeTag(declaration) && declaration.type) {
4712+
return links.type = getTypeFromTypeNode(declaration.type.type);
47134713
}
47144714
// Handle variable, parameter or property
47154715
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
@@ -6911,8 +6911,8 @@ namespace ts {
69116911
return isInJavaScriptFile(node) && (
69126912
// node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType
69136913
node.type && node.type.kind === SyntaxKind.JSDocOptionalType
6914-
|| getJSDocParameterTags(node).some(({ isBracketed, typeExpression }) =>
6915-
isBracketed || !!typeExpression && typeExpression.type.kind === SyntaxKind.JSDocOptionalType));
6914+
|| getJSDocParameterTags(node).some(({ isBracketed, type }) =>
6915+
isBracketed || !!type && type.type.kind === SyntaxKind.JSDocOptionalType));
69166916
}
69176917

69186918
function tryFindAmbientModule(moduleName: string, withAugmentations: boolean) {
@@ -7105,7 +7105,7 @@ namespace ts {
71057105
const lastParam = lastOrUndefined(declaration.parameters);
71067106
const lastParamTags = lastParam ? getJSDocParameterTags(lastParam) : getJSDocTags(declaration).filter(isJSDocParameterTag);
71077107
const lastParamVariadicType = firstDefined(lastParamTags, p =>
7108-
p.typeExpression && isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined);
7108+
p.type && isJSDocVariadicType(p.type.type) ? p.type.type : undefined);
71097109

71107110
const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args" as __String);
71117111
syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
@@ -15166,7 +15166,7 @@ namespace ts {
1516615166
case SyntaxKind.ParenthesizedExpression: {
1516715167
// Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast.
1516815168
const tag = isInJavaScriptFile(parent) ? getJSDocTypeTag(parent) : undefined;
15169-
return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(<ParenthesizedExpression>parent);
15169+
return tag ? getTypeFromTypeNode(tag.type.type) : getContextualType(<ParenthesizedExpression>parent);
1517015170
}
1517115171
case SyntaxKind.JsxExpression:
1517215172
return getContextualTypeForJsxExpression(<JsxExpression>parent);
@@ -20465,7 +20465,7 @@ namespace ts {
2046520465
function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type {
2046620466
const tag = isInJavaScriptFile(node) ? getJSDocTypeTag(node) : undefined;
2046720467
if (tag) {
20468-
return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
20468+
return checkAssertionWorker(tag, tag.type.type, node.expression, checkMode);
2046920469
}
2047020470
return checkExpression(node.expression, checkMode);
2047120471
}
@@ -22147,7 +22147,7 @@ namespace ts {
2214722147

2214822148
function checkJSDocTypedefTag(node: JSDocTypedefTag) {
2214922149
if (!node.type) {
22150-
// If the node had `@property` tags, `typeExpression` would have been set to the first property tag.
22150+
// If the node had `@property` tags, `type` would have been set to the first property tag.
2215122151
error(node.name, Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
2215222152
}
2215322153

@@ -22158,7 +22158,7 @@ namespace ts {
2215822158
}
2215922159

2216022160
function checkJSDocParameterTag(node: JSDocParameterTag) {
22161-
checkSourceElement(node.typeExpression);
22161+
checkSourceElement(node.type);
2216222162
if (!getParameterSymbolFromJSDoc(node)) {
2216322163
const decl = getHostSignatureFromJSDoc(node);
2216422164
// don't issue an error for invalid hosts -- just functions --
@@ -22175,8 +22175,8 @@ namespace ts {
2217522175
idText(node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name));
2217622176
}
2217722177
else if (findLast(getJSDocTags(decl), isJSDocParameterTag) === node &&
22178-
node.typeExpression && node.typeExpression.type &&
22179-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
22178+
node.type && node.type.type &&
22179+
!isArrayType(getTypeFromTypeNode(node.type.type))) {
2218022180
error(node.name,
2218122181
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type,
2218222182
idText(node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name));

src/compiler/parser.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,16 +465,16 @@ namespace ts {
465465
case SyntaxKind.JSDocPropertyTag:
466466
if ((node as JSDocPropertyLikeTag).isNameFirst) {
467467
return visitNode(cbNode, (<JSDocPropertyLikeTag>node).name) ||
468-
visitNode(cbNode, (<JSDocPropertyLikeTag>node).typeExpression);
468+
visitNode(cbNode, (<JSDocPropertyLikeTag>node).type);
469469
}
470470
else {
471-
return visitNode(cbNode, (<JSDocPropertyLikeTag>node).typeExpression) ||
471+
return visitNode(cbNode, (<JSDocPropertyLikeTag>node).type) ||
472472
visitNode(cbNode, (<JSDocPropertyLikeTag>node).name);
473473
}
474474
case SyntaxKind.JSDocReturnTag:
475-
return visitNode(cbNode, (<JSDocReturnTag>node).typeExpression);
475+
return visitNode(cbNode, (<JSDocReturnTag>node).type);
476476
case SyntaxKind.JSDocTypeTag:
477-
return visitNode(cbNode, (<JSDocTypeTag>node).typeExpression);
477+
return visitNode(cbNode, (<JSDocTypeTag>node).type);
478478
case SyntaxKind.JSDocAugmentsTag:
479479
return visitNode(cbNode, (<JSDocAugmentsTag>node).class);
480480
case SyntaxKind.JSDocTemplateTag:
@@ -6628,7 +6628,7 @@ namespace ts {
66286628
}
66296629
result.atToken = atToken;
66306630
result.tagName = tagName;
6631-
result.typeExpression = typeExpression;
6631+
result.type = typeExpression;
66326632
result.name = name;
66336633
result.isNameFirst = isNameFirst;
66346634
result.isBracketed = isBracketed;
@@ -6668,7 +6668,7 @@ namespace ts {
66686668
const result = <JSDocReturnTag>createNode(SyntaxKind.JSDocReturnTag, atToken.pos);
66696669
result.atToken = atToken;
66706670
result.tagName = tagName;
6671-
result.typeExpression = tryParseTypeExpression();
6671+
result.type = tryParseTypeExpression();
66726672
return finishNode(result);
66736673
}
66746674

@@ -6680,7 +6680,7 @@ namespace ts {
66806680
const result = <JSDocTypeTag>createNode(SyntaxKind.JSDocTypeTag, atToken.pos);
66816681
result.atToken = atToken;
66826682
result.tagName = tagName;
6683-
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
6683+
result.type = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
66846684
return finishNode(result);
66856685
}
66866686

@@ -6790,8 +6790,8 @@ namespace ts {
67906790
if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) {
67916791
jsdocTypeLiteral.isArrayType = true;
67926792
}
6793-
typedefTag.type = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
6794-
childTypeTag.typeExpression :
6793+
typedefTag.type = childTypeTag && childTypeTag.type && !isObjectOrObjectArrayTypeReference(childTypeTag.type.type) ?
6794+
childTypeTag.type :
67956795
finishNode(jsdocTypeLiteral);
67966796
}
67976797
}

src/compiler/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,12 +2371,12 @@ namespace ts {
23712371

23722372
export interface JSDocReturnTag extends JSDocTag {
23732373
kind: SyntaxKind.JSDocReturnTag;
2374-
typeExpression: JSDocTypeExpression;
2374+
type: JSDocTypeExpression;
23752375
}
23762376

23772377
export interface JSDocTypeTag extends JSDocTag {
23782378
kind: SyntaxKind.JSDocTypeTag;
2379-
typeExpression: JSDocTypeExpression;
2379+
type: JSDocTypeExpression;
23802380
}
23812381

23822382
export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
@@ -2406,7 +2406,7 @@ namespace ts {
24062406
export interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
24072407
parent: JSDoc;
24082408
name: EntityName;
2409-
typeExpression?: JSDocTypeExpression;
2409+
type?: JSDocTypeExpression;
24102410
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
24112411
isNameFirst: boolean;
24122412
isBracketed: boolean;

src/compiler/utilities.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4702,7 +4702,7 @@ namespace ts {
47024702
export function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined {
47034703
// We should have already issued an error if there were multiple type jsdocs, so just use the first one.
47044704
const tag = getFirstJSDocTag(node, isJSDocTypeTag);
4705-
if (tag && tag.typeExpression && tag.typeExpression.type) {
4705+
if (tag && tag.type && tag.type.type) {
47064706
return tag;
47074707
}
47084708
return undefined;
@@ -4722,10 +4722,10 @@ namespace ts {
47224722
export function getJSDocType(node: Node): TypeNode | undefined {
47234723
let tag: JSDocTypeTag | JSDocParameterTag | undefined = getFirstJSDocTag(node, isJSDocTypeTag);
47244724
if (!tag && isParameter(node)) {
4725-
tag = find(getJSDocParameterTags(node), tag => !!tag.typeExpression);
4725+
tag = find(getJSDocParameterTags(node), tag => !!tag.type);
47264726
}
47274727

4728-
return tag && tag.typeExpression && tag.typeExpression.type;
4728+
return tag && tag.type && tag.type.type;
47294729
}
47304730

47314731
/**
@@ -4736,7 +4736,7 @@ namespace ts {
47364736
*/
47374737
export function getJSDocReturnType(node: Node): TypeNode | undefined {
47384738
const returnTag = getJSDocReturnTag(node);
4739-
return returnTag && returnTag.typeExpression && returnTag.typeExpression.type;
4739+
return returnTag && returnTag.type && returnTag.type.type;
47404740
}
47414741

47424742
/** Get all JSDoc tags related to a node, including those on parent nodes. */

src/services/classifier.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,10 @@ namespace ts {
708708
processJSDocTemplateTag(<JSDocTemplateTag>tag);
709709
break;
710710
case SyntaxKind.JSDocTypeTag:
711-
processElement((<JSDocTypeTag>tag).typeExpression);
711+
processElement((<JSDocTypeTag>tag).type);
712712
break;
713713
case SyntaxKind.JSDocReturnTag:
714-
processElement((<JSDocReturnTag>tag).typeExpression);
714+
processElement((<JSDocReturnTag>tag).type);
715715
break;
716716
}
717717

@@ -732,10 +732,10 @@ namespace ts {
732732
pos = tag.name.end;
733733
}
734734

735-
if (tag.typeExpression) {
736-
pushCommentRange(pos, tag.typeExpression.pos - pos);
737-
processElement(tag.typeExpression);
738-
pos = tag.typeExpression.end;
735+
if (tag.type) {
736+
pushCommentRange(pos, tag.type.pos - pos);
737+
processElement(tag.type);
738+
pos = tag.type.end;
739739
}
740740

741741
if (!tag.isNameFirst) {

src/services/completions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,14 +817,14 @@ namespace ts.Completions {
817817
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
818818
return { kind: CompletionDataKind.JsDocTagName };
819819
}
820-
if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === SyntaxKind.JSDocTypeExpression) {
820+
if (isTagWithType(tag) && tag.type && tag.type.kind === SyntaxKind.JSDocTypeExpression) {
821821
currentToken = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true);
822822
if (!currentToken ||
823823
(!isDeclarationName(currentToken) &&
824824
(currentToken.parent.kind !== SyntaxKind.JSDocPropertyTag ||
825825
(<JSDocPropertyTag>currentToken.parent).name !== currentToken))) {
826826
// Use as type location if inside tag's type expression
827-
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
827+
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.type);
828828
}
829829
}
830830
if (isJSDocParameterTag(tag) && (nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
@@ -1002,9 +1002,9 @@ namespace ts.Completions {
10021002
const recommendedCompletion = previousToken && getRecommendedCompletion(previousToken, position, sourceFile, typeChecker);
10031003
return { kind: CompletionDataKind.Data, symbols, completionKind, isInSnippetScope, propertyAccessToConvert, isNewIdentifierLocation, location, keywordFilters, symbolToOriginInfoMap, recommendedCompletion, previousToken, isJsxInitializer };
10041004

1005-
type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag;
1005+
type JSDocTagWithType = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag;
10061006

1007-
function isTagWithTypeExpression(tag: JSDocTag): tag is JSDocTagWithTypeExpression {
1007+
function isTagWithType(tag: JSDocTag): tag is JSDocTagWithType {
10081008
switch (tag.kind) {
10091009
case SyntaxKind.JSDocParameterTag:
10101010
case SyntaxKind.JSDocPropertyTag:

src/services/jsDoc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace ts.JsDoc {
9696
case SyntaxKind.JSDocTemplateTag:
9797
return withList((tag as JSDocTemplateTag).typeParameters);
9898
case SyntaxKind.JSDocTypeTag:
99-
return withNode((tag as JSDocTypeTag).typeExpression);
99+
return withNode((tag as JSDocTypeTag).type);
100100
case SyntaxKind.JSDocTypedefTag:
101101
case SyntaxKind.JSDocPropertyTag:
102102
case SyntaxKind.JSDocParameterTag:

0 commit comments

Comments
 (0)