Skip to content

Preserve typedef comments in declaration emit#4365

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-comment-behavior-in-tsgo
Draft

Preserve typedef comments in declaration emit#4365
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-comment-behavior-in-tsgo

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

JSDoc descriptions preceding @typedef were not attached to the emitted declaration type. The full source JSDoc block could instead be emitted separately after the generated type.

  • Declaration emit

    • Preserve the descriptive portion of converted JSDoc typedef/callback comments on reparsed type aliases.
    • Avoid re-emitting converted @typedef/@callback source comments as standalone declaration trivia.
  • Baselines

    • Added regression coverage for typedef description emit.
    • Updated declaration baselines where converted JSDoc blocks are no longer duplicated.

Example output now matches the intended declaration shape:

/**
 * Comment on the `Foo` type
 */
export type Foo = {
    /**
     * Whether `.bool` is true or not
     */
    bool: boolean;
};

Copilot AI and others added 2 commits June 18, 2026 17:37
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix behavior difference for typedef comments in tsgo Preserve typedef comments in declaration emit Jun 18, 2026
Copilot AI requested a review from jakebailey June 18, 2026 17:44
Comment on lines -141 to -153
/**
* @overload evaluate(options = {}, [callback])
* Evaluate something
* @note Something interesting
* @param options [map]
* @return [string] returns evaluation result
* @return [null] returns nothing if callback provided
* @callback callback function (error, result)
* If callback is provided it will be called with evaluation result
* @param error [Error]
* @param result [String]
* @see callback
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks like this diff should not go away?

Comment on lines -38 to -41
/**
* @typedef {Record<Keyword, ParamValueTyped>} ParamStateRecord a Record containing
* keyword pairs with descriptions of parameters under governance.
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Now I am a bit confused..

Which actually counts as the comment for the generated type? The one on top of typedef, or the one follows right after the jsdoc declaration? Or both? Any precedence?

It worths to check how TS 6 behaves in all these cases. 🤔

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.

Behavior difference: Comment above @typedef does not become comment for the corresponding emitted type in tsgo

3 participants