Skip to content

Conversation

@xiaoxiangmoe
Copy link
Contributor

Fixes #48305

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Mar 18, 2022
Copy link
Contributor

@Kingwl Kingwl left a comment

Choose a reason for hiding this comment

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

LGTM

const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const));

preserveJsDoc(statement, input);
removeAllComments(input);
Copy link
Member

Choose a reason for hiding this comment

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

this is probably a question for @rbuckton , but why do you need to removeAllComments(input)? The other uses of preserveJSDoc don't do that.

@sandersn
Copy link
Member

sandersn commented Apr 7, 2022

I have a question about why removeAllComments is needed.

@Kingwl
Copy link
Contributor

Kingwl commented Apr 8, 2022

I have a question about why removeAllComments is needed.

The Input is still in the output code. And the preserveJsDoc will not remove the original comments.
It's will be duplicated if we don't remove the comments.

@xiaoxiangmoe
Copy link
Contributor Author

@sandersn

If I add removeAllComments(input);, it will be

/**
 * JSDoc Comments
 */
declare const _default: any;
export default _default;

If I remove removeAllComments(input);, it will be

/**
 * JSDoc Comments
 */
declare const _default: any;
/**
 * JSDoc Comments
 */
export default _default;

@sandersn sandersn merged commit 0885482 into microsoft:main Apr 27, 2022
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

JSDoc disappears after compilation

5 participants