Skip to content

Update types for SourceFile.jsDoc and JSDocTypeDefTag.typeExpression - #65572

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:more-ast-types
Nov 19, 2026
Merged

Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:more-ast-types

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Fixes #63877

I took a look at .parent types previously, doing some static analysis over ast.json, and found a lot of cases (particularly in parser recovery and grammar errors) where Strada's .parent type was a lie. We decided to keep it Node in the TS 7 API.

Comment thread tools/scripts/tsc/ast.json Outdated
{
"name": "TypeExpression",
"type": "Node",
"type": "TypeNode",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this can be stricter, JSDocTypeExpression | JSDocTypeLiteral

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 remain for the JSDoc API type refinements.

No open issues 🎉

1 file not reviewed
  • tsc/internal/ast/ast_generated.go: Generated file
What changed in this PR

Addresses #63877 by narrowing JSDoc properties in the TypeScript API while retaining Node as the parent type to accommodate parser recovery cases.

Changes:

  • Types Node.jsDoc as readonly JSDoc[] and typedef typeExpression as TypeNode.
  • Updates the AST schema, generators, and generated implementations consistently.
  • Adds API tests for typedef variants, visitor and clone behavior, and factory type constraints.
File Description
tsc/​internal/​ast/​ast_generated.go Narrows typedef fields and factory parameters.
tools/​scripts/​tsc/​generate-encoder.ts Generates typed JSDoc accessors.
tools/​scripts/​tsc/​ast.json Defines typedef expressions as type nodes.
packages/​typescript/​test/​sync/​ast.test.ts Tests narrowed contracts and removes an unnecessary cast.
packages/​typescript/​src/​ast/​visitor.generated.ts Validates typedef children with isTypeNode.
packages/​typescript/​src/​ast/​factory.generated.ts Narrows typedef factory parameters.
packages/​typescript/​src/​ast/​ast.ts Narrows the base node’s JSDoc property.
packages/​typescript/​src/​ast/​ast.generated.ts Narrows the typedef interface property.
packages/​typescript/​src/​api/​node/​node.generated.ts Exposes typed JSDoc arrays on remote nodes.

Review effort: Balanced

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 19, 2026
@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Nov 19, 2026
Merged via the queue into microsoft:main with commit 9c4ad5c Nov 19, 2026
34 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the more-ast-types branch November 19, 2026 00:54
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[API] Narrow types of Node attributes when possible

3 participants