@@ -507,8 +507,8 @@ namespace ts {
507507 const ancestorFacts = enterSubtree ( HierarchyFacts . SourceFileExcludes , HierarchyFacts . SourceFileIncludes ) ;
508508 const statements : Statement [ ] = [ ] ;
509509 startLexicalEnvironment ( ) ;
510- const statementOffset = addPrologueDirectives ( statements , node . statements , /*ensureUseStrict*/ false , visitor ) ;
511510 addCaptureThisForNodeIfNeeded ( statements , node ) ;
511+ const statementOffset = addPrologueDirectives ( statements , node . statements , /*ensureUseStrict*/ false , visitor ) ;
512512 addRange ( statements , visitNodes ( node . statements , visitor , isStatement , statementOffset ) ) ;
513513 addRange ( statements , endLexicalEnvironment ( ) ) ;
514514 exitSubtree ( ancestorFacts , HierarchyFacts . None , HierarchyFacts . None ) ;
@@ -915,14 +915,14 @@ namespace ts {
915915 // The assumption is that no prior step in the pipeline has added any prologue directives.
916916 statementOffset = 0 ;
917917 }
918- else if ( constructor ) {
919- // Otherwise, try to emit all potential prologue directives first.
920- statementOffset = addPrologueDirectives ( statements , constructor . body . statements , /*ensureUseStrict*/ false , visitor ) ;
921- }
922918
923919 if ( constructor ) {
924920 addDefaultValueAssignmentsIfNeeded ( statements , constructor ) ;
925921 addRestParameterIfNeeded ( statements , constructor , hasSynthesizedSuper ) ;
922+ if ( ! hasSynthesizedSuper ) {
923+ // If no super call has been synthesized, try to emit all potential prologue directives.
924+ statementOffset = addPrologueDirectives ( statements , constructor . body . statements , /*ensureUseStrict*/ false , visitor ) ;
925+ }
926926 Debug . assert ( statementOffset >= 0 , "statementOffset not initialized correctly!" ) ;
927927
928928 }
@@ -1806,15 +1806,8 @@ namespace ts {
18061806
18071807 const statements : Statement [ ] = [ ] ;
18081808 const body = node . body ;
1809- let statementOffset : number ;
18101809
18111810 resumeLexicalEnvironment ( ) ;
1812- if ( isBlock ( body ) ) {
1813- // ensureUseStrict is false because no new prologue-directive should be added.
1814- // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array
1815- statementOffset = addPrologueDirectives ( statements , body . statements , /*ensureUseStrict*/ false , visitor ) ;
1816- }
1817-
18181811 addCaptureThisForNodeIfNeeded ( statements , node ) ;
18191812 addDefaultValueAssignmentsIfNeeded ( statements , node ) ;
18201813 addRestParameterIfNeeded ( statements , node , /*inConstructorWithSynthesizedSuper*/ false ) ;
@@ -1825,6 +1818,10 @@ namespace ts {
18251818 }
18261819
18271820 if ( isBlock ( body ) ) {
1821+ // ensureUseStrict is false because no new prologue-directive should be added.
1822+ // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array
1823+ const statementOffset = addPrologueDirectives ( statements , body . statements , /*ensureUseStrict*/ false , visitor ) ;
1824+
18281825 statementsLocation = body . statements ;
18291826 addRange ( statements , visitNodes ( body . statements , visitor , isStatement , statementOffset ) ) ;
18301827
0 commit comments