Skip to content

Commit 66e2bd6

Browse files
author
Kanchalai Tanglertsampan
committed
Fix where we start checking for super-call
1 parent 32c9185 commit 66e2bd6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/compiler/emitter.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4766,9 +4766,14 @@ const _super = (function (geti, seti) {
47664766
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
47674767
}
47684768

4769-
function findInitialSuperCall(ctor: ConstructorDeclaration): ExpressionStatement {
4769+
/**
4770+
* Return the statement at a given index if it is a super-call statement
4771+
* @param ctor constructor declaration
4772+
* @param index an index to constructor's body to check
4773+
*/
4774+
function getSuperCallAtGivenIndex(ctor: ConstructorDeclaration, index: number): ExpressionStatement {
47704775
if (ctor.body) {
4771-
const statement = (<Block>ctor.body).statements[0];
4776+
const statement = (<Block>ctor.body).statements[index];
47724777
if (statement && statement.kind === SyntaxKind.ExpressionStatement) {
47734778
const expr = (<ExpressionStatement>statement).expression;
47744779
if (expr && expr.kind === SyntaxKind.CallExpression) {
@@ -5061,13 +5066,15 @@ const _super = (function (geti, seti) {
50615066
if (ctor) {
50625067
emitDefaultValueAssignments(ctor);
50635068
emitRestParameter(ctor);
5069+
50645070
if (baseTypeElement) {
5065-
superCall = findInitialSuperCall(ctor);
5071+
superCall = getSuperCallAtGivenIndex(ctor, startIndex);
50665072
if (superCall) {
50675073
writeLine();
50685074
emit(superCall);
50695075
}
50705076
}
5077+
50715078
emitParameterPropertyAssignments(ctor);
50725079
}
50735080
else {

0 commit comments

Comments
 (0)