Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDocTypeTag.typeExpression is not optional #30452

Merged
merged 2 commits into from Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Expand Up @@ -18344,7 +18344,7 @@ namespace ts {
case SyntaxKind.ParenthesizedExpression: {
// Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast.
const tag = isInJSFile(parent) ? getJSDocTypeTag(parent) : undefined;
return tag ? getTypeFromTypeNode(tag.typeExpression!.type) : getContextualType(<ParenthesizedExpression>parent, contextFlags);
return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(<ParenthesizedExpression>parent, contextFlags);
}
case SyntaxKind.JsxExpression:
return getContextualTypeForJsxExpression(<JsxExpression>parent);
Expand Down Expand Up @@ -23917,7 +23917,7 @@ namespace ts {
function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type {
const tag = isInJSFile(node) ? getJSDocTypeTag(node) : undefined;
if (tag) {
return checkAssertionWorker(tag, tag.typeExpression!.type, node.expression, checkMode);
return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
}
return checkExpression(node.expression, checkMode);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/factory.ts
Expand Up @@ -2189,7 +2189,7 @@ namespace ts {
}

/* @internal */
export function createJSDocTypeTag(typeExpression?: JSDocTypeExpression, comment?: string): JSDocTypeTag {
export function createJSDocTypeTag(typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag {
const tag = createJSDocTag<JSDocTypeTag>(SyntaxKind.JSDocTypeTag, "type");
tag.typeExpression = typeExpression;
tag.comment = comment;
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/parser.ts
Expand Up @@ -6853,7 +6853,7 @@ namespace ts {
}

function parseReturnTag(start: number, tagName: Identifier): JSDocReturnTag {
if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) {
if (some(tags, isJSDocReturnTag)) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText);
}

Expand All @@ -6864,7 +6864,7 @@ namespace ts {
}

function parseTypeTag(start: number, tagName: Identifier): JSDocTypeTag {
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) {
if (some(tags, isJSDocTypeTag)) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText);
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Expand Up @@ -2482,7 +2482,7 @@ namespace ts {

export interface JSDocTypeTag extends JSDocTag {
kind: SyntaxKind.JSDocTypeTag;
typeExpression?: JSDocTypeExpression;
typeExpression: JSDocTypeExpression;
}

export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
Expand Down
2 changes: 1 addition & 1 deletion src/services/jsDoc.ts
Expand Up @@ -134,7 +134,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).typeExpression);
case SyntaxKind.JSDocTypedefTag:
case SyntaxKind.JSDocCallbackTag:
case SyntaxKind.JSDocPropertyTag:
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Expand Up @@ -1603,7 +1603,7 @@ declare namespace ts {
}
interface JSDocTypeTag extends JSDocTag {
kind: SyntaxKind.JSDocTypeTag;
typeExpression?: JSDocTypeExpression;
typeExpression: JSDocTypeExpression;
}
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
parent: JSDoc;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/typescript.d.ts
Expand Up @@ -1603,7 +1603,7 @@ declare namespace ts {
}
interface JSDocTypeTag extends JSDocTag {
kind: SyntaxKind.JSDocTypeTag;
typeExpression?: JSDocTypeExpression;
typeExpression: JSDocTypeExpression;
}
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
parent: JSDoc;
Expand Down