diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fd0d4ad796e..9c8438565e7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4215,10 +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). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); @@ -4253,7 +4258,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(); 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;