Skip to content

Preserve original comments on params in dts generated by pseudo type node builder under removeComments: false#3263

Open
Andarist wants to merge 6 commits into
microsoft:mainfrom
Andarist:fix/comments-on-params-in-dts
Open

Preserve original comments on params in dts generated by pseudo type node builder under removeComments: false#3263
Andarist wants to merge 6 commits into
microsoft:mainfrom
Andarist:fix/comments-on-params-in-dts

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread internal/pseudochecker/lookup.go Outdated
Comment on lines +665 to +667
parameter.DotDotDotToken != nil,
e.Name(),
e.AsParameterDeclaration().QuestionToken != nil || e.AsParameterDeclaration().Initializer != nil,
ch.typeFromParameter(e.AsParameterDeclaration()),
parameter.QuestionToken != nil || parameter.Initializer != nil,
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.

At some level, why even have any of these if we are ferrying along the declaration?

(Or, why not just use p.Name.Parent more above?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At some level, why even have any of these if we are ferrying along the declaration?

ye, u are right here - since the new addition most of those other fields can just be read directly from the Declaration. I made that change.

Or, why not just use p.Name.Parent more above?

I thought about that but that felt indirect and not matching the style of all of those other fields on pseudochecker structs

@jakebailey
Copy link
Copy Markdown
Member

At some level, I wonder if this is even worth it.

@Andarist
Copy link
Copy Markdown
Contributor Author

At some level, I wonder if this is even worth it.

Fair. However, those are kinda jsdoc-like and shouldWriteComment explicitly allows those:
https://github.com/microsoft/TypeScript/blob/c7a0ae102dfb030c534a7bc31fbbd61a707dc9cf/src/compiler/emitter.ts#L6012-L6017

And the dts emitter configures the printer with onlyPrintJsDocStyle: true

@Andarist Andarist force-pushed the fix/comments-on-params-in-dts branch from 2a94731 to da2b88f Compare May 24, 2026 17:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates pseudo-parameter serialization so parameter-level comment ranges are preserved (and reflected in expected baselines) when emitting ES2015 output.

Changes:

  • Reintroduces parameter inline comments in the commentsFunction(target=es2015) baseline output.
  • Updates pseudo-parameter node building to derive rest/optional/name from the original declaration and to set comment ranges on emitted parameters.
  • Minor formatting change in PseudoParameter struct.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
testdata/baselines/reference/submoduleAccepted/compiler/commentsFunction(target=es2015).js.diff Removes an accepted reference baseline diff file for the commentsFunction ES2015 case.
testdata/baselines/reference/submodule/compiler/commentsFunction(target=es2015).js Updates baseline output to include inline parameter comments.
internal/pseudochecker/type.go Adjusts struct field spacing/alignment for PseudoParameter.Type.
internal/checker/pseudotypenodebuilder.go Builds parameter declarations from p.Declaration and applies comment ranges; updates optional detection in comparisons.
Comments suppressed due to low confidence (1)

testdata/baselines/reference/submoduleAccepted/compiler/commentsFunction(target=es2015).js.diff:1

  • This file is deleted entirely. If the test harness expects an 'accepted' reference baseline for this case, removing it can break baseline comparisons/CI. If the intent is to update the accepted output, consider keeping the file and updating its contents (or regenerating baselines consistently across both submodule and submoduleAccepted trees) rather than deleting just this reference.

Comment thread internal/pseudochecker/type.go Outdated
Comment thread internal/checker/pseudotypenodebuilder.go Outdated
Comment thread internal/checker/pseudotypenodebuilder.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants