From 1066f0e3cca7b1ddcf219490487edb7b13631ab5 Mon Sep 17 00:00:00 2001 From: "shyyko.serhiy@gmail.com" Date: Tue, 14 Jul 2015 15:28:05 +0300 Subject: [PATCH 1/4] fixed issue #3454 --- src/compiler/emitter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fd0d4ad796e..1c032c0aa25 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4219,6 +4219,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + var startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); @@ -4253,7 +4254,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(/*newLine*/ true); writeLine(); From aec0fb4818b7031fc1474b5497f084287e303133 Mon Sep 17 00:00:00 2001 From: "shyyko.serhiy@gmail.com" Date: Tue, 14 Jul 2015 17:02:18 +0300 Subject: [PATCH 2/4] fixed strictModeInConstructor baseline reference --- tests/baselines/reference/strictModeInConstructor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index 7fd74aa108f..7d1adc48fa0 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -74,8 +74,8 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - this.s = 9; "use strict"; // No error + this.s = 9; _super.call(this); } return B; From 12809125f8eb406e7743b75425595c065e8e05af Mon Sep 17 00:00:00 2001 From: "shyyko.serhiy@gmail.com" Date: Tue, 14 Jul 2015 17:21:47 +0300 Subject: [PATCH 3/4] added comment --- src/compiler/emitter.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1c032c0aa25..7b083ba7363 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4219,6 +4219,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). var startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } From 4cd7f079e3f1e1aac59c424d8090baefdfe2f1cb Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Jul 2015 16:43:13 -0700 Subject: [PATCH 4/4] Move startIndex declaration to the top --- src/compiler/emitter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 7b083ba7363..9c8438565e7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4215,13 +4215,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } + let startIndex = 0; + write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node);