Update to match old TS version: parameter properties after prologue

This commit is contained in:
John Lusty
2022-04-20 08:07:27 +01:00
parent bd2a2ecc31
commit d45098e23b
2 changed files with 10 additions and 16 deletions
+8 -14
View File
@@ -1359,22 +1359,16 @@ namespace ts {
if (parameterPropertyDeclarationCount > 0) {
const parameterProperties = visitNodes(constructor.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
// If there was a super() call found, add parameter properties immediately after it
if (superStatementIndex >= 0) {
addRange(statements, parameterProperties);
}
let superAndPrologueStatementCount = prologueStatementCount;
// If a synthetic super() call was added, add them just after it
else if (needsSyntheticConstructor) {
statements = [
statements[0],
...parameterProperties,
...statements.slice(1),
];
}
// Since there wasn't a super() call, add them to the top of the constructor
else {
statements = [...parameterProperties, ...statements];
if (needsSyntheticConstructor) {
superAndPrologueStatementCount += 1;
}
statements = [
...statements.slice(0, superAndPrologueStatementCount),
...parameterProperties,
...statements.slice(superAndPrologueStatementCount),
];
indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
}
@@ -45,8 +45,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
var _A_privateField, _B_privateField;
class A {
constructor(arg, exposedField) {
this.exposedField = exposedField;
var _a;
this.exposedField = exposedField;
_A_privateField.set(this, void 0);
(_a = this, { key: ({ set value(_b) { __classPrivateFieldSet(_a, _A_privateField, _b, "f"); } }).value } = arg);
}
@@ -58,9 +58,9 @@ class A {
_A_privateField = new WeakMap();
class B {
constructor(arg, exposedField) {
this.exposedField = exposedField;
"prologue";
var _a;
this.exposedField = exposedField;
_B_privateField.set(this, void 0);
(_a = this, { key: ({ set value(_b) { __classPrivateFieldSet(_a, _B_privateField, _b, "f"); } }).value } = arg);
}