@@ -515,8 +515,9 @@ namespace ts {
515515 const ancestorFacts = enterSubtree ( HierarchyFacts . SourceFileExcludes , HierarchyFacts . SourceFileIncludes ) ;
516516 const statements : Statement [ ] = [ ] ;
517517 startLexicalEnvironment ( ) ;
518+ let statementOffset = addPrologueDirectives ( statements , node . statements , /*ensureUseStrict*/ false ) ;
518519 addCaptureThisForNodeIfNeeded ( statements , node ) ;
519- const statementOffset = addPrologueDirectives ( statements , node . statements , /*ensureUseStrict*/ false , visitor ) ;
520+ statementOffset = addCustomPrologue ( statements , node . statements , statementOffset , visitor ) ;
520521 addRange ( statements , visitNodes ( node . statements , visitor , isStatement , statementOffset ) ) ;
521522 addRange ( statements , endLexicalEnvironment ( ) ) ;
522523 exitSubtree ( ancestorFacts , HierarchyFacts . None , HierarchyFacts . None ) ;
@@ -923,13 +924,16 @@ namespace ts {
923924 // The assumption is that no prior step in the pipeline has added any prologue directives.
924925 statementOffset = 0 ;
925926 }
927+ else if ( constructor ) {
928+ statementOffset = addPrologueDirectives ( statements , constructor . body . statements , /*ensureUseStrict*/ false ) ;
929+ }
926930
927931 if ( constructor ) {
928932 addDefaultValueAssignmentsIfNeeded ( statements , constructor ) ;
929933 addRestParameterIfNeeded ( statements , constructor , hasSynthesizedSuper ) ;
930934 if ( ! hasSynthesizedSuper ) {
931- // If no super call has been synthesized, try to emit all potential prologue directives.
932- statementOffset = addPrologueDirectives ( statements , constructor . body . statements , /*ensureUseStrict*/ false , visitor ) ;
935+ // If no super call has been synthesized, emit custom prologue directives.
936+ statementOffset = addCustomPrologue ( statements , constructor . body . statements , statementOffset , visitor ) ;
933937 }
934938 Debug . assert ( statementOffset >= 0 , "statementOffset not initialized correctly!" ) ;
935939
@@ -1816,8 +1820,15 @@ namespace ts {
18161820
18171821 const statements : Statement [ ] = [ ] ;
18181822 const body = node . body ;
1823+ let statementOffset : number ;
18191824
18201825 resumeLexicalEnvironment ( ) ;
1826+ if ( isBlock ( body ) ) {
1827+ // ensureUseStrict is false because no new prologue-directive should be added.
1828+ // addPrologueDirectives will put already-existing directives at the beginning of the target statement-array
1829+ statementOffset = addPrologueDirectives ( statements , body . statements , /*ensureUseStrict*/ false ) ;
1830+ }
1831+
18211832 addCaptureThisForNodeIfNeeded ( statements , node ) ;
18221833 addDefaultValueAssignmentsIfNeeded ( statements , node ) ;
18231834 addRestParameterIfNeeded ( statements , node , /*inConstructorWithSynthesizedSuper*/ false ) ;
@@ -1828,9 +1839,8 @@ namespace ts {
18281839 }
18291840
18301841 if ( isBlock ( body ) ) {
1831- // ensureUseStrict is false because no new prologue-directive should be added.
1832- // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array
1833- const statementOffset = addPrologueDirectives ( statements , body . statements , /*ensureUseStrict*/ false , visitor ) ;
1842+ // addCustomPrologue puts already-existing directives at the beginning of the target statement-array
1843+ statementOffset = addCustomPrologue ( statements , body . statements , statementOffset , visitor ) ;
18341844
18351845 statementsLocation = body . statements ;
18361846 addRange ( statements , visitNodes ( body . statements , visitor , isStatement , statementOffset ) ) ;
0 commit comments