Fix export default expression comment (#48323)

This commit is contained in:
ZHAO Jinxiang 2022-04-28 07:33:46 +08:00 committed by GitHub
parent 476fc625df
commit 0885482eeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 0 deletions

View File

@ -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);
return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
}
}

View File

@ -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;

View File

@ -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.

View File

@ -0,0 +1,7 @@
=== tests/cases/conformance/declarationEmit/exportDefaultExpressionComments.ts ===
/**
* JSDoc Comments
*/
export default null
>null : null

View File

@ -0,0 +1,6 @@
// @declaration: true
/**
* JSDoc Comments
*/
export default null