@@ -91,7 +91,7 @@ namespace ts {
9191
9292 // If this file is an external module, then it is automatically in strict-mode according to
9393 // ES6. If it is not an external module, then we'll determine if it is in strict mode or
94- // not depending on if we see "use strict" in certain places.
94+ // not depending on if we see "use strict" in certain places (or if we hit a class/namespace) .
9595 let inStrictMode = ! ! file . externalModuleIndicator ;
9696
9797 let symbolCount = 0 ;
@@ -538,10 +538,13 @@ namespace ts {
538538 }
539539
540540 function bindObjectLiteralExpression ( node : ObjectLiteralExpression ) {
541+ const enum ElementKind {
542+ Property = 1 ,
543+ Accessor = 2
544+ }
545+
541546 if ( inStrictMode ) {
542- let seen : Map < number > = { } ;
543- const Property = 1 ;
544- const NonProperty = 2 ;
547+ let seen : Map < ElementKind > = { } ;
545548
546549 for ( let prop of node . properties ) {
547550 if ( prop . name . kind !== SyntaxKind . Identifier ) {
@@ -559,16 +562,16 @@ namespace ts {
559562 // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
560563 // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
561564 let currentKind = prop . kind === SyntaxKind . PropertyAssignment || prop . kind === SyntaxKind . ShorthandPropertyAssignment || prop . kind === SyntaxKind . MethodDeclaration
562- ? Property
563- : NonProperty ;
565+ ? ElementKind . Property
566+ : ElementKind . Accessor ;
564567
565568 let existingKind = seen [ identifier . text ] ;
566569 if ( ! existingKind ) {
567570 seen [ identifier . text ] = currentKind ;
568571 continue ;
569572 }
570573
571- if ( currentKind === Property && existingKind === Property ) {
574+ if ( currentKind === ElementKind . Property && existingKind === ElementKind . Property ) {
572575 let span = getErrorSpanForNode ( file , identifier ) ;
573576 file . bindDiagnostics . push ( createFileDiagnostic ( file , span . start , span . length ,
574577 Diagnostics . An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode ) ) ;
@@ -798,17 +801,16 @@ namespace ts {
798801 return ;
799802 }
800803
801- if ( isUseStrictPrologueDirective ( statement ) ) {
804+ if ( isUseStrictPrologueDirective ( < ExpressionStatement > statement ) ) {
802805 inStrictMode = true ;
803806 return ;
804807 }
805808 }
806809 }
807810
808811 /// Should be called only on prologue directives (isPrologueDirective(node) should be true)
809- function isUseStrictPrologueDirective ( node : Node ) : boolean {
810- Debug . assert ( isPrologueDirective ( node ) ) ;
811- let nodeText = getTextOfNodeFromSourceText ( file . text , ( < ExpressionStatement > node ) . expression ) ;
812+ function isUseStrictPrologueDirective ( node : ExpressionStatement ) : boolean {
813+ let nodeText = getTextOfNodeFromSourceText ( file . text , node . expression ) ;
812814
813815 // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
814816 // string to contain unicode escapes (as per ES5).
@@ -838,9 +840,9 @@ namespace ts {
838840 return declareSymbolAndAddToSymbolTable ( < Declaration > node , SymbolFlags . TypeParameter , SymbolFlags . TypeParameterExcludes ) ;
839841 case SyntaxKind . Parameter :
840842 return bindParameter ( < ParameterDeclaration > node ) ;
841- case SyntaxKind . BindingElement :
842843 case SyntaxKind . VariableDeclaration :
843- return bindVariableDeclarationOrBindingElement ( < BindingElement | VariableDeclaration > node ) ;
844+ case SyntaxKind . BindingElement :
845+ return bindVariableDeclarationOrBindingElement ( < VariableDeclaration | BindingElement > node ) ;
844846 case SyntaxKind . PropertyDeclaration :
845847 case SyntaxKind . PropertySignature :
846848 return bindPropertyOrMethodOrAccessor ( < Declaration > node , SymbolFlags . Property | ( ( < PropertyDeclaration > node ) . questionToken ? SymbolFlags . Optional : SymbolFlags . None ) , SymbolFlags . PropertyExcludes ) ;
0 commit comments