镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Handle JSDocParameterTag in ast.GetTypeAnnotationNode - #64617

Open
auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:fix-jsdoc-param-type-annotation
Open

auvred wants to merge 1 commit into
microsoft:mainfrom
auvred:fix-jsdoc-param-type-annotation

Conversation

@auvred

@auvred auvred commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

I just randomly noticed that GetTypeAnnotationNode calls Node.Type(), which handles both JSDoc parameter and property tags:

case KindJSDocParameterTag, KindJSDocPropertyTag:
return n.AsJSDocParameterOrPropertyTag().TypeExpression

but its own switch only includes property tags. So, for consistency, this function must have the parameter tag case missed in microsoft/typescript-go#900. No user-facing change, since the only caller doesn't pass JSDoc tags

// We don't want to complete using the type acquired by the shape
// of the binding pattern; we are only interested in types acquired
// through type declaration or inference.
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
// type of parameter will flow in from the contextual type of the function.
canGetType := ast.HasInitializer(rootDeclaration) ||
ast.GetTypeAnnotationNode(rootDeclaration) != nil ||
rootDeclaration.Parent.Parent.Kind == ast.KindForOfStatement

Copilot AI balanced review requested due to automatic review settings October 3, 2026 08:19
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 3, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 3, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new AST utility behavior lacks a focused regression test.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Extends AST type annotation lookup to handle JSDoc parameter tags consistently.

Changes:

  • Adds KindJSDocParameterTag to GetTypeAnnotationNode.
File Description
tsc/​internal/​ast/​utilities.go Supports retrieving JSDoc parameter type expressions.

KindAsExpression, KindSatisfiesExpression, KindTypeAliasDeclaration, KindJSTypeAliasDeclaration,
KindNamedTupleMember, KindOptionalType, KindRestType, KindTemplateLiteralTypeSpan, KindJSDocTypeExpression,
KindJSDocPropertyTag, KindJSDocNullableType, KindJSDocNonNullableType, KindJSDocOptionalType:
KindJSDocParameterTag, KindJSDocPropertyTag, KindJSDocNullableType, KindJSDocNonNullableType, KindJSDocOptionalType:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫩

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants