mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Don't replace the last statement if 'this' is used/captured within the constructor.
This commit is contained in:
@@ -1024,8 +1024,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// Return the result if we have an immediate super() call on the last statement.
|
||||
if (superCallExpression && statementOffset === ctorStatements.length - 1) {
|
||||
// Return the result if we have an immediate super() call on the last statement,
|
||||
// but only if the constructor itself doesn't use 'this' elsewhere.
|
||||
if (superCallExpression
|
||||
&& statementOffset === ctorStatements.length - 1
|
||||
&& !(ctor.transformFlags & (TransformFlags.ContainsLexicalThis | TransformFlags.ContainsCapturedLexicalThis))) {
|
||||
const returnStatement = createReturn(superCallExpression);
|
||||
|
||||
if (superCallExpression.kind !== SyntaxKind.BinaryExpression
|
||||
|
||||
Reference in New Issue
Block a user