mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
fix(43298): copy comments on converting from arrow function to anonymous function (#44236)
This commit is contained in:
@@ -177,7 +177,11 @@ namespace ts.refactor.convertArrowFunctionOrFunctionExpression {
|
||||
|
||||
function convertToBlock(body: ConciseBody): Block {
|
||||
if (isExpression(body)) {
|
||||
return factory.createBlock([factory.createReturnStatement(body)], /* multiLine */ true);
|
||||
const returnStatement = factory.createReturnStatement(body);
|
||||
const file = body.getSourceFile();
|
||||
suppressLeadingAndTrailingTrivia(returnStatement);
|
||||
copyTrailingAsLeadingComments(body, returnStatement, file, /* commentKind */ undefined, /* hasTrailingNewLine */ true);
|
||||
return factory.createBlock([returnStatement], /* multiLine */ true);
|
||||
}
|
||||
else {
|
||||
return body;
|
||||
|
||||
Reference in New Issue
Block a user