@@ -121,7 +121,8 @@ namespace ts {
121121
122122 // If this file is an external module, then it is automatically in strict-mode according to
123123 // ES6. If it is not an external module, then we'll determine if it is in strict mode or
124- // not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
124+ // not depending on if we see "use strict" in certain places or if we hit a class/namespace
125+ // or if compiler options contain alwaysStrict.
125126 let inStrictMode : boolean ;
126127
127128 let symbolCount = 0 ;
@@ -139,7 +140,7 @@ namespace ts {
139140 file = f ;
140141 options = opts ;
141142 languageVersion = getEmitScriptTarget ( options ) ;
142- inStrictMode = ! ! file . externalModuleIndicator ;
143+ inStrictMode = bindInStrictMode ( file , opts ) ;
143144 classifiableNames = createMap < string > ( ) ;
144145 symbolCount = 0 ;
145146 skipTransformFlagAggregation = isDeclarationFile ( file ) ;
@@ -174,6 +175,16 @@ namespace ts {
174175
175176 return bindSourceFile ;
176177
178+ function bindInStrictMode ( file : SourceFile , opts : CompilerOptions ) : boolean {
179+ if ( opts . alwaysStrict && ! isDeclarationFile ( file ) ) {
180+ // bind in strict mode source files with alwaysStrict option
181+ return true ;
182+ }
183+ else {
184+ return ! ! file . externalModuleIndicator ;
185+ }
186+ }
187+
177188 function createSymbol ( flags : SymbolFlags , name : string ) : Symbol {
178189 symbolCount ++ ;
179190 return new Symbol ( flags , name ) ;
0 commit comments