11/// <reference path="parser.ts"/>
22
33module ts {
4- /* @internal */ export var bindTime = 0 ;
4+ /* @internal */ export let bindTime = 0 ;
55
66 export const enum ModuleInstanceState {
77 NonInstantiated = 0 ,
@@ -25,7 +25,7 @@ module ts {
2525 }
2626 // 4. other uninstantiated module declarations.
2727 else if ( node . kind === SyntaxKind . ModuleBlock ) {
28- var state = ModuleInstanceState . NonInstantiated ;
28+ let state = ModuleInstanceState . NonInstantiated ;
2929 forEachChild ( node , n => {
3030 switch ( getModuleInstanceState ( n ) ) {
3131 case ModuleInstanceState . NonInstantiated :
@@ -52,18 +52,18 @@ module ts {
5252 }
5353
5454 export function bindSourceFile ( file : SourceFile ) : void {
55- var start = new Date ( ) . getTime ( ) ;
55+ let start = new Date ( ) . getTime ( ) ;
5656 bindSourceFileWorker ( file ) ;
5757 bindTime += new Date ( ) . getTime ( ) - start ;
5858 }
5959
6060 function bindSourceFileWorker ( file : SourceFile ) : void {
6161 var parent : Node ;
62- var container : Node ;
63- var blockScopeContainer : Node ;
64- var lastContainer : Node ;
65- var symbolCount = 0 ;
66- var Symbol = objectAllocator . getSymbolConstructor ( ) ;
62+ let container : Node ;
63+ let blockScopeContainer : Node ;
64+ let lastContainer : Node ;
65+ let symbolCount = 0 ;
66+ let Symbol = objectAllocator . getSymbolConstructor ( ) ;
6767
6868 if ( ! file . locals ) {
6969 file . locals = { } ;
@@ -103,7 +103,7 @@ module ts {
103103 return '"' + ( < LiteralExpression > node . name ) . text + '"' ;
104104 }
105105 if ( node . name . kind === SyntaxKind . ComputedPropertyName ) {
106- var nameExpression = ( < ComputedPropertyName > node . name ) . expression ;
106+ let nameExpression = ( < ComputedPropertyName > node . name ) . expression ;
107107 Debug . assert ( isWellKnownSymbolSyntactically ( nameExpression ) ) ;
108108 return getPropertyNameForKnownSymbolName ( ( < PropertyAccessExpression > nameExpression ) . name . text ) ;
109109 }
@@ -138,18 +138,19 @@ module ts {
138138 Debug . assert ( ! hasDynamicName ( node ) ) ;
139139
140140 // The exported symbol for an export default function/class node is always named "default"
141- var name = node . flags & NodeFlags . Default && parent ? "default" : getDeclarationName ( node ) ;
141+ let name = node . flags & NodeFlags . Default && parent ? "default" : getDeclarationName ( node ) ;
142142
143+ let symbol : Symbol ;
143144 if ( name !== undefined ) {
144- var symbol = hasProperty ( symbols , name ) ? symbols [ name ] : ( symbols [ name ] = createSymbol ( 0 , name ) ) ;
145+ symbol = hasProperty ( symbols , name ) ? symbols [ name ] : ( symbols [ name ] = createSymbol ( 0 , name ) ) ;
145146 if ( symbol . flags & excludes ) {
146147 if ( node . name ) {
147148 node . name . parent = node ;
148149 }
149150
150151 // Report errors every position with duplicate declaration
151152 // Report errors on previous encountered declarations
152- var message = symbol . flags & SymbolFlags . BlockScopedVariable
153+ let message = symbol . flags & SymbolFlags . BlockScopedVariable
153154 ? Diagnostics . Cannot_redeclare_block_scoped_variable_0
154155 : Diagnostics . Duplicate_identifier_0 ;
155156
@@ -172,7 +173,7 @@ module ts {
172173 // Every class automatically contains a static property member named 'prototype',
173174 // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
174175 // It is an error to explicitly declare a static property member with the name 'prototype'.
175- var prototypeSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Prototype , "prototype" ) ;
176+ let prototypeSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Prototype , "prototype" ) ;
176177 if ( hasProperty ( symbol . exports , prototypeSymbol . name ) ) {
177178 if ( node . name ) {
178179 node . name . parent = node ;
@@ -196,7 +197,7 @@ module ts {
196197 }
197198
198199 function declareModuleMember ( node : Declaration , symbolKind : SymbolFlags , symbolExcludes : SymbolFlags ) {
199- var hasExportModifier = getCombinedNodeFlags ( node ) & NodeFlags . Export ;
200+ let hasExportModifier = getCombinedNodeFlags ( node ) & NodeFlags . Export ;
200201 if ( symbolKind & SymbolFlags . Alias ) {
201202 if ( node . kind === SyntaxKind . ExportSpecifier || ( node . kind === SyntaxKind . ImportEqualsDeclaration && hasExportModifier ) ) {
202203 declareSymbol ( container . symbol . exports , container . symbol , node , symbolKind , symbolExcludes ) ;
@@ -218,10 +219,10 @@ module ts {
218219 // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
219220 // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
220221 if ( hasExportModifier || isAmbientContext ( container ) ) {
221- var exportKind = ( symbolKind & SymbolFlags . Value ? SymbolFlags . ExportValue : 0 ) |
222+ let exportKind = ( symbolKind & SymbolFlags . Value ? SymbolFlags . ExportValue : 0 ) |
222223 ( symbolKind & SymbolFlags . Type ? SymbolFlags . ExportType : 0 ) |
223224 ( symbolKind & SymbolFlags . Namespace ? SymbolFlags . ExportNamespace : 0 ) ;
224- var local = declareSymbol ( container . locals , undefined , node , exportKind , symbolExcludes ) ;
225+ let local = declareSymbol ( container . locals , undefined , node , exportKind , symbolExcludes ) ;
225226 local . exportSymbol = declareSymbol ( container . symbol . exports , container . symbol , node , symbolKind , symbolExcludes ) ;
226227 node . localSymbol = local ;
227228 }
@@ -238,9 +239,9 @@ module ts {
238239 node . locals = { } ;
239240 }
240241
241- var saveParent = parent ;
242- var saveContainer = container ;
243- var savedBlockScopeContainer = blockScopeContainer ;
242+ let saveParent = parent ;
243+ let saveContainer = container ;
244+ let savedBlockScopeContainer = blockScopeContainer ;
244245 parent = node ;
245246 if ( symbolKind & SymbolFlags . IsContainer ) {
246247 container = node ;
@@ -315,7 +316,7 @@ module ts {
315316 bindDeclaration ( node , SymbolFlags . ValueModule , SymbolFlags . ValueModuleExcludes , /*isBlockScopeContainer*/ true ) ;
316317 }
317318 else {
318- var state = getModuleInstanceState ( node ) ;
319+ let state = getModuleInstanceState ( node ) ;
319320 if ( state === ModuleInstanceState . NonInstantiated ) {
320321 bindDeclaration ( node , SymbolFlags . NamespaceModule , SymbolFlags . NamespaceModuleExcludes , /*isBlockScopeContainer*/ true ) ;
321322 }
@@ -341,18 +342,18 @@ module ts {
341342 // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
342343 // from an actual type literal symbol you would have gotten had you used the long form.
343344
344- var symbol = createSymbol ( SymbolFlags . Signature , getDeclarationName ( node ) ) ;
345+ let symbol = createSymbol ( SymbolFlags . Signature , getDeclarationName ( node ) ) ;
345346 addDeclarationToSymbol ( symbol , node , SymbolFlags . Signature ) ;
346347 bindChildren ( node , SymbolFlags . Signature , /*isBlockScopeContainer:*/ false ) ;
347348
348- var typeLiteralSymbol = createSymbol ( SymbolFlags . TypeLiteral , "__type" ) ;
349+ let typeLiteralSymbol = createSymbol ( SymbolFlags . TypeLiteral , "__type" ) ;
349350 addDeclarationToSymbol ( typeLiteralSymbol , node , SymbolFlags . TypeLiteral ) ;
350351 typeLiteralSymbol . members = { } ;
351352 typeLiteralSymbol . members [ node . kind === SyntaxKind . FunctionType ? "__call" : "__new" ] = symbol
352353 }
353354
354355 function bindAnonymousDeclaration ( node : Declaration , symbolKind : SymbolFlags , name : string , isBlockScopeContainer : boolean ) {
355- var symbol = createSymbol ( symbolKind , name ) ;
356+ let symbol = createSymbol ( symbolKind , name ) ;
356357 addDeclarationToSymbol ( symbol , node , symbolKind ) ;
357358 bindChildren ( node , symbolKind , isBlockScopeContainer ) ;
358359 }
@@ -525,9 +526,9 @@ module ts {
525526 // Otherwise this won't be considered as redeclaration of a block scoped local:
526527 // function foo() {
527528 // let x;
528- // var x;
529+ // let x;
529530 // }
530- // 'var x' will be placed into the function locals and 'let x' - into the locals of the block
531+ // 'let x' will be placed into the function locals and 'let x' - into the locals of the block
531532 bindChildren ( node , 0 , /*isBlockScopeContainer*/ ! isFunctionLike ( node . parent ) ) ;
532533 break ;
533534 case SyntaxKind . CatchClause :
@@ -538,7 +539,7 @@ module ts {
538539 bindChildren ( node , 0 , /*isBlockScopeContainer*/ true ) ;
539540 break ;
540541 default :
541- var saveParent = parent ;
542+ let saveParent = parent ;
542543 parent = node ;
543544 forEachChild ( node , bind ) ;
544545 parent = saveParent ;
@@ -559,7 +560,7 @@ module ts {
559560 node . parent . kind === SyntaxKind . Constructor &&
560561 node . parent . parent . kind === SyntaxKind . ClassDeclaration ) {
561562
562- var classDeclaration = < ClassDeclaration > node . parent . parent ;
563+ let classDeclaration = < ClassDeclaration > node . parent . parent ;
563564 declareSymbol ( classDeclaration . symbol . members , classDeclaration . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
564565 }
565566 }
0 commit comments