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