mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Move synthetic comments from arrow body expressions to return statement (#24135)
This commit is contained in:
@@ -2900,6 +2900,15 @@ namespace ts {
|
||||
return setSyntheticTrailingComments(node, append<SynthesizedComment>(getSyntheticTrailingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text }));
|
||||
}
|
||||
|
||||
export function moveSyntheticComments<T extends Node>(node: T, original: Node): T {
|
||||
setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
|
||||
setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
|
||||
const emit = getOrCreateEmitNode(original);
|
||||
emit.leadingComments = undefined;
|
||||
emit.trailingComments = undefined;
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the constant value to emit for an expression.
|
||||
*/
|
||||
|
||||
@@ -1885,6 +1885,7 @@ namespace ts {
|
||||
const expression = visitNode(body, visitor, isExpression);
|
||||
const returnStatement = createReturn(expression);
|
||||
setTextRange(returnStatement, body);
|
||||
moveSyntheticComments(returnStatement, body);
|
||||
setEmitFlags(returnStatement, EmitFlags.NoTokenSourceMaps | EmitFlags.NoTrailingSourceMap | EmitFlags.NoTrailingComments);
|
||||
statements.push(returnStatement);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user