diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 77e2d76bfdb..cff2be7fb78 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -1359,16 +1359,21 @@ namespace ts { if (parameterPropertyDeclarationCount > 0) { const parameterProperties = visitNodes(constructor.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); - let superAndPrologueStatementCount = prologueStatementCount; - // If a synthetic super() call was added, add them just after it - if (needsSyntheticConstructor) { - superAndPrologueStatementCount += 1; + // If there was a super() call found, add parameter properties immediately after it + if (superStatementIndex >= 0) { + addRange(statements, parameterProperties); + } + else { + // Add add parameter properties to the top of the constructor after the prologue + let superAndPrologueStatementCount = prologueStatementCount; + // If a synthetic super() call was added, need to account for that + if (needsSyntheticConstructor) superAndPrologueStatementCount++; + statements = [ + ...statements.slice(0, superAndPrologueStatementCount), + ...parameterProperties, + ...statements.slice(superAndPrologueStatementCount), + ]; } - statements = [ - ...statements.slice(0, superAndPrologueStatementCount), - ...parameterProperties, - ...statements.slice(superAndPrologueStatementCount), - ]; indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; }