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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
}
}
Expand Down
22 changes: 22 additions & 0 deletions tests/baselines/reference/exportDefaultExpressionComments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//// [exportDefaultExpressionComments.ts]
/**
* JSDoc Comments
*/
export default null


//// [exportDefaultExpressionComments.js]
"use strict";
exports.__esModule = true;
/**
* JSDoc Comments
*/
exports["default"] = null;


//// [exportDefaultExpressionComments.d.ts]
/**
* JSDoc Comments
*/
declare const _default: any;
export default _default;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
=== tests/cases/conformance/declarationEmit/exportDefaultExpressionComments.ts ===
/**
No type information for this code. * JSDoc Comments
No type information for this code. */
No type information for this code.export default null
No type information for this code.
No type information for this code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
=== tests/cases/conformance/declarationEmit/exportDefaultExpressionComments.ts ===
/**
* JSDoc Comments
*/
export default null
>null : null

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @declaration: true

/**
* JSDoc Comments
*/
export default null