Skip to content

Fix incorrect node type annotations - #65489

Merged
Jake Bailey (jakebailey) merged 4 commits into
microsoft:mainfrom
jakebailey:compiler-fixes/ast-node-annotations
Nov 17, 2026
Merged

Jake Bailey (jakebailey) merged 4 commits into
microsoft:mainfrom
jakebailey:compiler-fixes/ast-node-annotations

Conversation

@jakebailey

Copy link
Copy Markdown
Member

This came up in an audit; these type annotations are incorrect.

The reuse helper also processes property names and type parameter
declarations. A TypeNode annotation misrepresents these supported
callers even though Go accepts the node aliases interchangeably.
Named evaluation transforms preserve the surrounding declaration kinds.
Describing their results as expressions hides the contracts expected by
their callers.
The type serializer checks arbitrary serialized expressions for
generated-name metadata. Restricting this helper's annotation to
identifiers misrepresents a supported caller.
Declaration names can be string literals, binding patterns, or computed
names, and namespace member names are property accesses. Identifier
result annotations misrepresent those node kinds even though Go accepts
the node aliases interchangeably.

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.

🟢 Approval recommended

No active review issues are reported for the AST node type annotation corrections.

No open issues 🎉

What changed in this PR

Corrects AST node type annotations in the native TypeScript compiler to match the nodes each helper accepts or returns. These alias-only changes leave runtime behavior unchanged.

Changes:

  • Uses general node annotations for helpers that support multiple node kinds.
  • Uses concrete return annotations for named-evaluation helpers and namespace member access.
File Description
tsc/​internal/​transformers/​utilities.go Allows the generated-identifier predicate to accept any node.
tsc/​internal/​transformers/​estransforms/​namedevaluation.go Corrects helper return types and broadens the dispatcher’s return annotation.
tsc/​internal/​printer/​factory.go Broadens declaration-name annotations and identifies namespace member results as property access nodes.
tsc/​internal/​checker/​nodecopy.go Generalizes the node-reuse helper’s parameter and return annotations.

Review effort: Balanced

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 17, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Nov 17, 2026
Merged via the queue into microsoft:main with commit aacfe85 Nov 17, 2026
34 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the compiler-fixes/ast-node-annotations branch November 17, 2026 21:50
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants