@@ -279,7 +279,7 @@ namespace ts {
279
279
else if ( node . transformFlags & TransformFlags . ContainsES2015 || ( isInConstructorWithCapturedSuper && ! isExpression ( node ) ) ) {
280
280
// we want to dive in this branch either if node has children with ES2015 specific syntax
281
281
// 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
283
283
return visitEachChild ( node , visitor , context ) ;
284
284
}
285
285
else {
@@ -1011,7 +1011,20 @@ namespace ts {
1011
1011
1012
1012
// Return the result if we have an immediate super() call on the last statement.
1013
1013
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 ) ;
1015
1028
return SuperCaptureResult . ReplaceWithReturn ;
1016
1029
}
1017
1030
0 commit comments