Skip to content

Commit 71f24f3

Browse files
committed
fix(53204): call __runInitializers after super() call
1 parent 9ccf47f commit 71f24f3

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

src/compiler/transformers/esDecorators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,8 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc
10721072
if (initializerStatements) {
10731073
const statements: Statement[] = [];
10741074
const nonPrologueStart = factory.copyPrologue(node.body.statements, statements, /*ensureUseStrict*/ false, visitor);
1075-
addRange(statements, initializerStatements);
10761075
addRange(statements, visitNodes(node.body.statements, visitor, isStatement, nonPrologueStart));
1076+
addRange(statements, initializerStatements);
10771077
body = factory.createBlock(statements, /*multiLine*/ true);
10781078
setOriginalNode(body, node.body);
10791079
setTextRange(body, node.body);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//// [esDecorators-classExpression-classSuper.7.ts]
2+
class A {}
3+
class B extends A {
4+
public constructor() {
5+
super();
6+
}
7+
8+
@foo
9+
public m(): void {}
10+
}
11+
12+
function foo(method: any, _context: any): any {
13+
return function (this: any) {
14+
method.call(this);
15+
};
16+
}
17+
18+
new B();
19+
20+
21+
//// [esDecorators-classExpression-classSuper.7.js]
22+
class A {
23+
}
24+
let B = (() => {
25+
let _instanceExtraInitializers = [];
26+
let _m_decorators;
27+
return class B extends A {
28+
static {
29+
_m_decorators = [foo];
30+
__esDecorate(this, null, _m_decorators, { kind: "method", name: "m", static: false, private: false, access: { has: obj => "m" in obj, get: obj => obj.m } }, null, _instanceExtraInitializers);
31+
}
32+
constructor() {
33+
super();
34+
__runInitializers(this, _instanceExtraInitializers);
35+
}
36+
m() { }
37+
};
38+
})();
39+
function foo(method, _context) {
40+
return function () {
41+
method.call(this);
42+
};
43+
}
44+
new B();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @target: es2022
2+
// @noEmitHelpers: true
3+
// @noTypesAndSymbols: true
4+
5+
class A {}
6+
class B extends A {
7+
public constructor() {
8+
super();
9+
}
10+
11+
@foo
12+
public m(): void {}
13+
}
14+
15+
function foo(method: any, _context: any): any {
16+
return function (this: any) {
17+
method.call(this);
18+
};
19+
}
20+
21+
new B();

0 commit comments

Comments
 (0)