mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Rename the rest of typeExpressions
Turns out there is a constraint in services such that they all need to be named the same.
This commit is contained in:
@@ -2214,7 +2214,7 @@ namespace ts {
|
||||
// falls through
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
const propTag = node as JSDocPropertyLikeTag;
|
||||
const flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType ?
|
||||
const flags = propTag.isBracketed || propTag.type && propTag.type.type.kind === SyntaxKind.JSDocOptionalType ?
|
||||
SymbolFlags.Property | SymbolFlags.Optional :
|
||||
SymbolFlags.Property;
|
||||
return declareSymbolAndAddToSymbolTable(propTag, flags, SymbolFlags.PropertyExcludes);
|
||||
|
||||
+11
-11
@@ -4708,8 +4708,8 @@ namespace ts {
|
||||
if (declaration.kind === SyntaxKind.ExportAssignment) {
|
||||
return links.type = checkExpression((<ExportAssignment>declaration).expression);
|
||||
}
|
||||
if (isInJavaScriptFile(declaration) && isJSDocPropertyLikeTag(declaration) && declaration.typeExpression) {
|
||||
return links.type = getTypeFromTypeNode(declaration.typeExpression.type);
|
||||
if (isInJavaScriptFile(declaration) && isJSDocPropertyLikeTag(declaration) && declaration.type) {
|
||||
return links.type = getTypeFromTypeNode(declaration.type.type);
|
||||
}
|
||||
// Handle variable, parameter or property
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
@@ -6911,8 +6911,8 @@ namespace ts {
|
||||
return isInJavaScriptFile(node) && (
|
||||
// node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType
|
||||
node.type && node.type.kind === SyntaxKind.JSDocOptionalType
|
||||
|| getJSDocParameterTags(node).some(({ isBracketed, typeExpression }) =>
|
||||
isBracketed || !!typeExpression && typeExpression.type.kind === SyntaxKind.JSDocOptionalType));
|
||||
|| getJSDocParameterTags(node).some(({ isBracketed, type }) =>
|
||||
isBracketed || !!type && type.type.kind === SyntaxKind.JSDocOptionalType));
|
||||
}
|
||||
|
||||
function tryFindAmbientModule(moduleName: string, withAugmentations: boolean) {
|
||||
@@ -7105,7 +7105,7 @@ namespace ts {
|
||||
const lastParam = lastOrUndefined(declaration.parameters);
|
||||
const lastParamTags = lastParam ? getJSDocParameterTags(lastParam) : getJSDocTags(declaration).filter(isJSDocParameterTag);
|
||||
const lastParamVariadicType = firstDefined(lastParamTags, p =>
|
||||
p.typeExpression && isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined);
|
||||
p.type && isJSDocVariadicType(p.type.type) ? p.type.type : undefined);
|
||||
|
||||
const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args" as __String);
|
||||
syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
|
||||
@@ -15166,7 +15166,7 @@ namespace ts {
|
||||
case SyntaxKind.ParenthesizedExpression: {
|
||||
// Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast.
|
||||
const tag = isInJavaScriptFile(parent) ? getJSDocTypeTag(parent) : undefined;
|
||||
return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(<ParenthesizedExpression>parent);
|
||||
return tag ? getTypeFromTypeNode(tag.type.type) : getContextualType(<ParenthesizedExpression>parent);
|
||||
}
|
||||
case SyntaxKind.JsxExpression:
|
||||
return getContextualTypeForJsxExpression(<JsxExpression>parent);
|
||||
@@ -20465,7 +20465,7 @@ namespace ts {
|
||||
function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type {
|
||||
const tag = isInJavaScriptFile(node) ? getJSDocTypeTag(node) : undefined;
|
||||
if (tag) {
|
||||
return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
|
||||
return checkAssertionWorker(tag, tag.type.type, node.expression, checkMode);
|
||||
}
|
||||
return checkExpression(node.expression, checkMode);
|
||||
}
|
||||
@@ -22147,7 +22147,7 @@ namespace ts {
|
||||
|
||||
function checkJSDocTypedefTag(node: JSDocTypedefTag) {
|
||||
if (!node.type) {
|
||||
// If the node had `@property` tags, `typeExpression` would have been set to the first property tag.
|
||||
// If the node had `@property` tags, `type` 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);
|
||||
}
|
||||
|
||||
@@ -22158,7 +22158,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkJSDocParameterTag(node: JSDocParameterTag) {
|
||||
checkSourceElement(node.typeExpression);
|
||||
checkSourceElement(node.type);
|
||||
if (!getParameterSymbolFromJSDoc(node)) {
|
||||
const decl = getHostSignatureFromJSDoc(node);
|
||||
// don't issue an error for invalid hosts -- just functions --
|
||||
@@ -22175,8 +22175,8 @@ namespace ts {
|
||||
idText(node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name));
|
||||
}
|
||||
else if (findLast(getJSDocTags(decl), isJSDocParameterTag) === node &&
|
||||
node.typeExpression && node.typeExpression.type &&
|
||||
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
||||
node.type && node.type.type &&
|
||||
!isArrayType(getTypeFromTypeNode(node.type.type))) {
|
||||
error(node.name,
|
||||
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,
|
||||
idText(node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name));
|
||||
|
||||
@@ -465,16 +465,16 @@ namespace ts {
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
if ((node as JSDocPropertyLikeTag).isNameFirst) {
|
||||
return visitNode(cbNode, (<JSDocPropertyLikeTag>node).name) ||
|
||||
visitNode(cbNode, (<JSDocPropertyLikeTag>node).typeExpression);
|
||||
visitNode(cbNode, (<JSDocPropertyLikeTag>node).type);
|
||||
}
|
||||
else {
|
||||
return visitNode(cbNode, (<JSDocPropertyLikeTag>node).typeExpression) ||
|
||||
return visitNode(cbNode, (<JSDocPropertyLikeTag>node).type) ||
|
||||
visitNode(cbNode, (<JSDocPropertyLikeTag>node).name);
|
||||
}
|
||||
case SyntaxKind.JSDocReturnTag:
|
||||
return visitNode(cbNode, (<JSDocReturnTag>node).typeExpression);
|
||||
return visitNode(cbNode, (<JSDocReturnTag>node).type);
|
||||
case SyntaxKind.JSDocTypeTag:
|
||||
return visitNode(cbNode, (<JSDocTypeTag>node).typeExpression);
|
||||
return visitNode(cbNode, (<JSDocTypeTag>node).type);
|
||||
case SyntaxKind.JSDocAugmentsTag:
|
||||
return visitNode(cbNode, (<JSDocAugmentsTag>node).class);
|
||||
case SyntaxKind.JSDocTemplateTag:
|
||||
@@ -6628,7 +6628,7 @@ namespace ts {
|
||||
}
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.typeExpression = typeExpression;
|
||||
result.type = typeExpression;
|
||||
result.name = name;
|
||||
result.isNameFirst = isNameFirst;
|
||||
result.isBracketed = isBracketed;
|
||||
@@ -6668,7 +6668,7 @@ namespace ts {
|
||||
const result = <JSDocReturnTag>createNode(SyntaxKind.JSDocReturnTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.typeExpression = tryParseTypeExpression();
|
||||
result.type = tryParseTypeExpression();
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
@@ -6680,7 +6680,7 @@ namespace ts {
|
||||
const result = <JSDocTypeTag>createNode(SyntaxKind.JSDocTypeTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
|
||||
result.type = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
@@ -6790,8 +6790,8 @@ namespace ts {
|
||||
if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) {
|
||||
jsdocTypeLiteral.isArrayType = true;
|
||||
}
|
||||
typedefTag.type = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
|
||||
childTypeTag.typeExpression :
|
||||
typedefTag.type = childTypeTag && childTypeTag.type && !isObjectOrObjectArrayTypeReference(childTypeTag.type.type) ?
|
||||
childTypeTag.type :
|
||||
finishNode(jsdocTypeLiteral);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2371,12 +2371,12 @@ namespace ts {
|
||||
|
||||
export interface JSDocReturnTag extends JSDocTag {
|
||||
kind: SyntaxKind.JSDocReturnTag;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
type: JSDocTypeExpression;
|
||||
}
|
||||
|
||||
export interface JSDocTypeTag extends JSDocTag {
|
||||
kind: SyntaxKind.JSDocTypeTag;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
type: JSDocTypeExpression;
|
||||
}
|
||||
|
||||
export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
@@ -2406,7 +2406,7 @@ namespace ts {
|
||||
export interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
|
||||
parent: JSDoc;
|
||||
name: EntityName;
|
||||
typeExpression?: JSDocTypeExpression;
|
||||
type?: JSDocTypeExpression;
|
||||
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
|
||||
isNameFirst: boolean;
|
||||
isBracketed: boolean;
|
||||
|
||||
@@ -4702,7 +4702,7 @@ namespace ts {
|
||||
export function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined {
|
||||
// We should have already issued an error if there were multiple type jsdocs, so just use the first one.
|
||||
const tag = getFirstJSDocTag(node, isJSDocTypeTag);
|
||||
if (tag && tag.typeExpression && tag.typeExpression.type) {
|
||||
if (tag && tag.type && tag.type.type) {
|
||||
return tag;
|
||||
}
|
||||
return undefined;
|
||||
@@ -4722,10 +4722,10 @@ namespace ts {
|
||||
export function getJSDocType(node: Node): TypeNode | undefined {
|
||||
let tag: JSDocTypeTag | JSDocParameterTag | undefined = getFirstJSDocTag(node, isJSDocTypeTag);
|
||||
if (!tag && isParameter(node)) {
|
||||
tag = find(getJSDocParameterTags(node), tag => !!tag.typeExpression);
|
||||
tag = find(getJSDocParameterTags(node), tag => !!tag.type);
|
||||
}
|
||||
|
||||
return tag && tag.typeExpression && tag.typeExpression.type;
|
||||
return tag && tag.type && tag.type.type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4736,7 +4736,7 @@ namespace ts {
|
||||
*/
|
||||
export function getJSDocReturnType(node: Node): TypeNode | undefined {
|
||||
const returnTag = getJSDocReturnTag(node);
|
||||
return returnTag && returnTag.typeExpression && returnTag.typeExpression.type;
|
||||
return returnTag && returnTag.type && returnTag.type.type;
|
||||
}
|
||||
|
||||
/** Get all JSDoc tags related to a node, including those on parent nodes. */
|
||||
|
||||
@@ -708,10 +708,10 @@ namespace ts {
|
||||
processJSDocTemplateTag(<JSDocTemplateTag>tag);
|
||||
break;
|
||||
case SyntaxKind.JSDocTypeTag:
|
||||
processElement((<JSDocTypeTag>tag).typeExpression);
|
||||
processElement((<JSDocTypeTag>tag).type);
|
||||
break;
|
||||
case SyntaxKind.JSDocReturnTag:
|
||||
processElement((<JSDocReturnTag>tag).typeExpression);
|
||||
processElement((<JSDocReturnTag>tag).type);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -732,10 +732,10 @@ namespace ts {
|
||||
pos = tag.name.end;
|
||||
}
|
||||
|
||||
if (tag.typeExpression) {
|
||||
pushCommentRange(pos, tag.typeExpression.pos - pos);
|
||||
processElement(tag.typeExpression);
|
||||
pos = tag.typeExpression.end;
|
||||
if (tag.type) {
|
||||
pushCommentRange(pos, tag.type.pos - pos);
|
||||
processElement(tag.type);
|
||||
pos = tag.type.end;
|
||||
}
|
||||
|
||||
if (!tag.isNameFirst) {
|
||||
|
||||
@@ -817,14 +817,14 @@ namespace ts.Completions {
|
||||
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
|
||||
return { kind: CompletionDataKind.JsDocTagName };
|
||||
}
|
||||
if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === SyntaxKind.JSDocTypeExpression) {
|
||||
if (isTagWithType(tag) && tag.type && tag.type.kind === SyntaxKind.JSDocTypeExpression) {
|
||||
currentToken = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
if (!currentToken ||
|
||||
(!isDeclarationName(currentToken) &&
|
||||
(currentToken.parent.kind !== SyntaxKind.JSDocPropertyTag ||
|
||||
(<JSDocPropertyTag>currentToken.parent).name !== currentToken))) {
|
||||
// Use as type location if inside tag's type expression
|
||||
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
|
||||
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.type);
|
||||
}
|
||||
}
|
||||
if (isJSDocParameterTag(tag) && (nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
|
||||
@@ -1002,9 +1002,9 @@ namespace ts.Completions {
|
||||
const recommendedCompletion = previousToken && getRecommendedCompletion(previousToken, position, sourceFile, typeChecker);
|
||||
return { kind: CompletionDataKind.Data, symbols, completionKind, isInSnippetScope, propertyAccessToConvert, isNewIdentifierLocation, location, keywordFilters, symbolToOriginInfoMap, recommendedCompletion, previousToken, isJsxInitializer };
|
||||
|
||||
type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag;
|
||||
type JSDocTagWithType = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag;
|
||||
|
||||
function isTagWithTypeExpression(tag: JSDocTag): tag is JSDocTagWithTypeExpression {
|
||||
function isTagWithType(tag: JSDocTag): tag is JSDocTagWithType {
|
||||
switch (tag.kind) {
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace ts.JsDoc {
|
||||
case SyntaxKind.JSDocTemplateTag:
|
||||
return withList((tag as JSDocTemplateTag).typeParameters);
|
||||
case SyntaxKind.JSDocTypeTag:
|
||||
return withNode((tag as JSDocTypeTag).typeExpression);
|
||||
return withNode((tag as JSDocTypeTag).type);
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
|
||||
Reference in New Issue
Block a user