mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 06:41:59 -06:00
Move comments from super calls to their generated return statements.
This commit is contained in:
parent
63f70dc09a
commit
2f6ba0876c
@ -279,7 +279,7 @@ namespace ts {
|
||||
else if (node.transformFlags & TransformFlags.ContainsES2015 || (isInConstructorWithCapturedSuper && !isExpression(node))) {
|
||||
// we want to dive in this branch either if node has children with ES2015 specific syntax
|
||||
// or we are inside constructor that captures result of the super call so all returns without expression should be
|
||||
// rewritten. Note: we skip expressions since returns should never appear there
|
||||
// rewritten. Note: we skip expressions since returns should never appear there
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
else {
|
||||
@ -1011,7 +1011,20 @@ namespace ts {
|
||||
|
||||
// Return the result if we have an immediate super() call on the last statement.
|
||||
if (superCallExpression && statementOffset === ctorStatements.length - 1) {
|
||||
statements.push(createReturn(superCallExpression));
|
||||
const returnStatement = createReturn(superCallExpression);
|
||||
|
||||
if (superCallExpression.kind !== SyntaxKind.BinaryExpression
|
||||
&& (superCallExpression as BinaryExpression).left.kind !== SyntaxKind.CallExpression) {
|
||||
Debug.fail("Assumed generated super call would have form 'super.call(...) || this'.");
|
||||
}
|
||||
|
||||
// Shift comments from the original super call to the return statement.
|
||||
setCommentRange(returnStatement, getCommentRange(
|
||||
setEmitFlags(
|
||||
(superCallExpression as BinaryExpression).left,
|
||||
EmitFlags.NoComments)));
|
||||
|
||||
statements.push(returnStatement);
|
||||
return SuperCaptureResult.ReplaceWithReturn;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user