Preserve JSDoc @property comments when reconstructing typedef types - #4674
Preserve JSDoc @property comments when reconstructing typedef types#4674Alex Khizhnyi (veksa) wants to merge 1 commit into
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Preserves JSDoc @property descriptions when typedef structures are synthesized into declaration types.
Changes:
- Reattaches reparsed JSDoc as synthetic leading comments.
- Adds a cross-file JavaScript declaration test and baselines.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/checker/nodebuilderimpl.go |
Preserves comments on synthesized properties. |
testdata/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypedefPropertyComments.ts |
Adds regression coverage. |
testdata/baselines/reference/conformance/jsDeclarationsTypedefPropertyComments.js |
Verifies declaration output. |
testdata/baselines/reference/conformance/jsDeclarationsTypedefPropertyComments.types |
Records inferred types. |
testdata/baselines/reference/conformance/jsDeclarationsTypedefPropertyComments.symbols |
Records symbol bindings. |
1ed642a to
9a5d5bf
Compare
|
Thank you for contributing to the TypeScript native port! Development has moved from this repository back to the main microsoft/TypeScript repository. GitHub does not have PR transfer functionality, so we're closing this PR here. If this change is still relevant, please reopen it as a new pull request in See microsoft/typescript-go#4918 for more information about the move. |
Fixes microsoft/TypeScript#63839
Problem
Block comments on
@propertyentries of a@typedefwere dropped when the structural type was reconstructed inline in another file. TypeScript 6 preserves them;tsgodid not.main.d.tsbefore (comment lost):main.d.tsafter (matchestsc):Fix
The old JS
.d.tsemitter copied comments onto synthesized property signatures viapreserveCommentsOn/setSyntheticLeadingComments. The Go node builder used a rawsetCommentRangeinaddPropertyToElementList, which drops comments for properties reparsed from@typedef/@propertytags — their comment lives on a synthetic reparsed JSDoc rather than in a source comment range.This reimplements
preserveCommentsOninsideaddPropertyToElementList: for a property whose declaration is a reparsed node carrying JSDoc, the comment text is reattached as a synthetic leading comment; otherwise the existingsetCommentRangebehavior is preserved. Only reparsed JS@propertydeclarations take the new path, so TS declaration emit is unaffected.Tests
Adds
jsDeclarationsTypedefPropertyComments.tscovering both the same-file type alias and the cross-file inline reconstruction. Full local compiler suite andchecker/transformer package tests pass.AI usage disclosure
This change was authored with the assistance of an AI agent (Claude Code). I have read and understand the change and will discuss and revise it in review like any other contribution.