Skip to content

Fix incorrect node type annotations - #65489

Open
Jake Bailey (jakebailey) wants to merge 4 commits into
microsoft:mainfrom
jakebailey:compiler-fixes/ast-node-annotations
Open

Jake Bailey (jakebailey) wants to merge 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

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

Author: Team 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