Preserve JSDoc @property comments when reconstructing typedef types#4674
Open
veksa wants to merge 1 commit into
Open
Preserve JSDoc @property comments when reconstructing typedef types#4674veksa wants to merge 1 commit into
veksa wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4352
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.