Skip to content

Commit 0885482

Browse files
authoredApr 27, 2022
Fix export default expression comment (microsoft#48323)
1 parent 476fc62 commit 0885482

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed
 

Diff for: ‎src/compiler/transformers/declarations.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,9 @@ namespace ts {
11401140
const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
11411141
errorFallbackNode = undefined;
11421142
const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const));
1143+
1144+
preserveJsDoc(statement, input);
1145+
removeAllComments(input);
11431146
return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
11441147
}
11451148
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [exportDefaultExpressionComments.ts]
2+
/**
3+
* JSDoc Comments
4+
*/
5+
export default null
6+
7+
8+
//// [exportDefaultExpressionComments.js]
9+
"use strict";
10+
exports.__esModule = true;
11+
/**
12+
* JSDoc Comments
13+
*/
14+
exports["default"] = null;
15+
16+
17+
//// [exportDefaultExpressionComments.d.ts]
18+
/**
19+
* JSDoc Comments
20+
*/
21+
declare const _default: any;
22+
export default _default;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/conformance/declarationEmit/exportDefaultExpressionComments.ts ===
2+
/**
3+
No type information for this code. * JSDoc Comments
4+
No type information for this code. */
5+
No type information for this code.export default null
6+
No type information for this code.
7+
No type information for this code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/conformance/declarationEmit/exportDefaultExpressionComments.ts ===
2+
/**
3+
* JSDoc Comments
4+
*/
5+
export default null
6+
>null : null
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @declaration: true
2+
3+
/**
4+
* JSDoc Comments
5+
*/
6+
export default null

0 commit comments

Comments
 (0)
Please sign in to comment.