Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix export default expression comment #48323

Merged
merged 1 commit into from
Apr 27, 2022
Merged

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

@@ -1140,6 +1140,9 @@ namespace ts {
const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
errorFallbackNode = undefined;
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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