Skip to content

feat(printer): implement JSDoc node emission in AST printer - #65058

Open
el-j (el-j) wants to merge 4 commits into
microsoft:release-7.1from
el-j:feat/jsdoc-printer
Open

el-j (el-j) wants to merge 4 commits into
microsoft:release-7.1from
el-j:feat/jsdoc-printer

Conversation

@el-j

@el-j el-j (el-j) commented Oct 30, 2026 •

Copy link
Copy Markdown

Fixes #65057

Implements canonical JSDoc block and tag emission, including parameter types and inline links. Adds printer tests for direct JSDoc printing and JSDoc attached to declarations.

Also adds synthetic leading/trailing comment support to the JS API's printNode/printFile, so JSDoc can be attached to synthesized nodes and printed without a source file:

  • JS: addSyntheticLeadingComment/addSyntheticTrailingComment (and getters/setters) are exported from @typescript/typescript/ast; the encoder sends them as an optional comments field on printNode.
  • Go: printNode applies them to an EmitContext, validating node indices and comment kinds. A new opt-in printer option, EmitSyntheticCommentsWithoutSourceFile, emits them when no source file is present; it is only enabled by printNode, so other printing paths are unchanged.
  • Tests: Go printer and API tests, plus async/sync JS API tests.

Validation: npx hereby validate --api passed (974 API tests, 0 lint issues; requires Node 24).

AI disclosure: This PR was created with assistance from GitHub Copilot (Copilot SDK in VS Code). Automated validation passed; author review and Microsoft CLA agreement remain pending.

Note: My GitHub account lacks permission to assign issue #65057 to the Backlog milestone, so that required checklist item remains unchecked.

Related issues and PRs

Issues

Pull requests

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

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.

🟡 Changes recommended

Unresolved JSDoc printer defects cause panics and invalid or lossy output, including broken signature handling, malformed imports, and dropped template parameter defaults and modifiers.

9 open issues
What changed in this PR

This PR adds JSDoc AST emission to the native TypeScript printer, addressing the unimplemented printing path reported in #65057.

Changes:

  • Adds emission for JSDoc blocks, tags, type expressions, names, and inline links.
  • Introduces helpers for comment formatting and JSDoc type literals.
  • Adds printer tests for direct JSDoc emission and preservation of comments attached to declarations.
File Description
tsc/​internal/​printer/​printer.go Implements JSDoc dispatch, formatting, and tag emission.
tsc/​internal/​printer/​printer_test.go Adds coverage for JSDoc blocks, parameter types, links, and attached comments.

Review effort: Balanced

Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
el-j (el-j) and others added 2 commits October 30, 2026 17:04
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@el-j
el-j (el-j) changed the base branch from main to release-7.1 October 30, 2026 16:09
@el-j

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@el-j

Copy link
Copy Markdown
Author

I have addressed all nine review threads and pushed the update to release-7.1; npx hereby validate and the focused printer tests pass locally. The branch protection rules show one approving review and a required required status check in addition to the passing CLA check. The upstream CI and CodeQL runs for this fork PR are currently action_required, so they need approval from someone with repository permissions. Could a maintainer approve the pending workflows and review the updated PR?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Comment thread tsc/internal/printer/printer.go Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@el-j

Copy link
Copy Markdown
Author

Follow-up: I addressed the five new review comments in 4c2c6fa, including preserving nested property comments and links, optional JSDoc properties, generic callback/overload tag ordering, and namespaced typedef names. All 14 review threads are resolved, and go -C ./tsc test ./internal/printer plus npx hereby validate pass locally. The updated SHA has no upstream CI runs/statuses yet, and the PR still needs an approving review. Could a maintainer re-review and enable the required CI checks?

Carry synthetic leading/trailing comments from the JS API to the Go printer
and emit them when printing nodes without a source file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Native printer panics when printing JSDoc AST nodes

2 participants