@@ -279,7 +279,7 @@ namespace ts {
279279 else if ( node . transformFlags & TransformFlags . ContainsES2015 || ( isInConstructorWithCapturedSuper && ! isExpression ( node ) ) ) {
280280 // we want to dive in this branch either if node has children with ES2015 specific syntax
281281 // or we are inside constructor that captures result of the super call so all returns without expression should be
282- // rewritten. Note: we skip expressions since returns should never appear there
282+ // rewritten. Note: we skip expressions since returns should never appear there
283283 return visitEachChild ( node , visitor , context ) ;
284284 }
285285 else {
@@ -1011,7 +1011,20 @@ namespace ts {
10111011
10121012 // Return the result if we have an immediate super() call on the last statement.
10131013 if ( superCallExpression && statementOffset === ctorStatements . length - 1 ) {
1014- statements . push ( createReturn ( superCallExpression ) ) ;
1014+ const returnStatement = createReturn ( superCallExpression ) ;
1015+
1016+ if ( superCallExpression . kind !== SyntaxKind . BinaryExpression
1017+ && ( superCallExpression as BinaryExpression ) . left . kind !== SyntaxKind . CallExpression ) {
1018+ Debug . fail ( "Assumed generated super call would have form 'super.call(...) || this'." ) ;
1019+ }
1020+
1021+ // Shift comments from the original super call to the return statement.
1022+ setCommentRange ( returnStatement , getCommentRange (
1023+ setEmitFlags (
1024+ ( superCallExpression as BinaryExpression ) . left ,
1025+ EmitFlags . NoComments ) ) ) ;
1026+
1027+ statements . push ( returnStatement ) ;
10151028 return SuperCaptureResult . ReplaceWithReturn ;
10161029 }
10171030
0 commit comments