@@ -133,7 +133,7 @@ namespace ts {
133
133
134
134
let symbolCount = 0 ;
135
135
let Symbol : { new ( flags : SymbolFlags , name : string ) : Symbol } ;
136
- let classifiableNames : Map < string > ;
136
+ let classifiableNames : Set < string > ;
137
137
138
138
const unreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
139
139
const reportedUnreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
@@ -147,7 +147,7 @@ namespace ts {
147
147
options = opts ;
148
148
languageVersion = getEmitScriptTarget ( options ) ;
149
149
inStrictMode = bindInStrictMode ( file , opts ) ;
150
- classifiableNames = createMap < string > ( ) ;
150
+ classifiableNames = createSet ( ) ;
151
151
symbolCount = 0 ;
152
152
skipTransformFlagAggregation = isDeclarationFile ( file ) ;
153
153
@@ -207,11 +207,11 @@ namespace ts {
207
207
symbol . declarations . push ( node ) ;
208
208
209
209
if ( symbolFlags & SymbolFlags . HasExports && ! symbol . exports ) {
210
- symbol . exports = createMap < Symbol > ( ) ;
210
+ symbol . exports = createMap < string , Symbol > ( ) ;
211
211
}
212
212
213
213
if ( symbolFlags & SymbolFlags . HasMembers && ! symbol . members ) {
214
- symbol . members = createMap < Symbol > ( ) ;
214
+ symbol . members = createMap < string , Symbol > ( ) ;
215
215
}
216
216
217
217
if ( symbolFlags & SymbolFlags . Value ) {
@@ -349,17 +349,17 @@ namespace ts {
349
349
// Otherwise, we'll be merging into a compatible existing symbol (for example when
350
350
// you have multiple 'vars' with the same name in the same container). In this case
351
351
// just add this node into the declarations list of the symbol.
352
- symbol = symbolTable [ name ] || ( symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ) ;
352
+ symbol = getOrUpdate ( symbolTable , name , name => createSymbol ( SymbolFlags . None , name ) ) ;
353
353
354
354
if ( name && ( includes & SymbolFlags . Classifiable ) ) {
355
- classifiableNames [ name ] = name ;
355
+ classifiableNames . add ( name ) ;
356
356
}
357
357
358
358
if ( symbol . flags & excludes ) {
359
359
if ( symbol . isReplaceableByMethod ) {
360
360
// Javascript constructor-declared symbols can be discarded in favor of
361
361
// prototype symbols like methods.
362
- symbol = symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ;
362
+ symbol = setAndReturn ( symbolTable , name , createSymbol ( SymbolFlags . None , name ) ) ;
363
363
}
364
364
else {
365
365
if ( node . name ) {
@@ -484,7 +484,7 @@ namespace ts {
484
484
if ( containerFlags & ContainerFlags . IsContainer ) {
485
485
container = blockScopeContainer = node ;
486
486
if ( containerFlags & ContainerFlags . HasLocals ) {
487
- container . locals = createMap < Symbol > ( ) ;
487
+ container . locals = createMap < string , Symbol > ( ) ;
488
488
}
489
489
addToContainerChain ( container ) ;
490
490
}
@@ -1525,8 +1525,7 @@ namespace ts {
1525
1525
1526
1526
const typeLiteralSymbol = createSymbol ( SymbolFlags . TypeLiteral , "__type" ) ;
1527
1527
addDeclarationToSymbol ( typeLiteralSymbol , node , SymbolFlags . TypeLiteral ) ;
1528
- typeLiteralSymbol . members = createMap < Symbol > ( ) ;
1529
- typeLiteralSymbol . members [ symbol . name ] = symbol ;
1528
+ typeLiteralSymbol . members = createMap ( [ [ symbol . name , symbol ] ] ) ;
1530
1529
}
1531
1530
1532
1531
function bindObjectLiteralExpression ( node : ObjectLiteralExpression ) {
@@ -1536,7 +1535,7 @@ namespace ts {
1536
1535
}
1537
1536
1538
1537
if ( inStrictMode ) {
1539
- const seen = createMap < ElementKind > ( ) ;
1538
+ const seen = createMap < string , ElementKind > ( ) ;
1540
1539
1541
1540
for ( const prop of node . properties ) {
1542
1541
if ( prop . name . kind !== SyntaxKind . Identifier ) {
@@ -1557,9 +1556,9 @@ namespace ts {
1557
1556
? ElementKind . Property
1558
1557
: ElementKind . Accessor ;
1559
1558
1560
- const existingKind = seen [ identifier . text ] ;
1559
+ const existingKind = seen . get ( identifier . text ) ;
1561
1560
if ( ! existingKind ) {
1562
- seen [ identifier . text ] = currentKind ;
1561
+ seen . set ( identifier . text , currentKind ) ;
1563
1562
continue ;
1564
1563
}
1565
1564
@@ -1592,7 +1591,7 @@ namespace ts {
1592
1591
// fall through.
1593
1592
default :
1594
1593
if ( ! blockScopeContainer . locals ) {
1595
- blockScopeContainer . locals = createMap < Symbol > ( ) ;
1594
+ blockScopeContainer . locals = createMap < string , Symbol > ( ) ;
1596
1595
addToContainerChain ( blockScopeContainer ) ;
1597
1596
}
1598
1597
declareSymbol ( blockScopeContainer . locals , undefined , node , symbolFlags , symbolExcludes ) ;
@@ -2072,7 +2071,7 @@ namespace ts {
2072
2071
}
2073
2072
}
2074
2073
2075
- file . symbol . globalExports = file . symbol . globalExports || createMap < Symbol > ( ) ;
2074
+ file . symbol . globalExports = file . symbol . globalExports || createMap < string , Symbol > ( ) ;
2076
2075
declareSymbol ( file . symbol . globalExports , file . symbol , node , SymbolFlags . Alias , SymbolFlags . AliasExcludes ) ;
2077
2076
}
2078
2077
@@ -2119,7 +2118,7 @@ namespace ts {
2119
2118
Debug . assert ( isInJavaScriptFile ( node ) ) ;
2120
2119
// Declare a 'member' if the container is an ES5 class or ES6 constructor
2121
2120
if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionExpression ) {
2122
- container . symbol . members = container . symbol . members || createMap < Symbol > ( ) ;
2121
+ container . symbol . members = container . symbol . members || createMap < string , Symbol > ( ) ;
2123
2122
// It's acceptable for multiple 'this' assignments of the same identifier to occur
2124
2123
declareSymbol ( container . symbol . members , container . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
2125
2124
}
@@ -2151,14 +2150,14 @@ namespace ts {
2151
2150
constructorFunction . parent = classPrototype ;
2152
2151
classPrototype . parent = leftSideOfAssignment ;
2153
2152
2154
- const funcSymbol = container . locals [ constructorFunction . text ] ;
2153
+ const funcSymbol = container . locals . get ( constructorFunction . text ) ;
2155
2154
if ( ! funcSymbol || ! ( funcSymbol . flags & SymbolFlags . Function || isDeclarationOfFunctionExpression ( funcSymbol ) ) ) {
2156
2155
return ;
2157
2156
}
2158
2157
2159
2158
// Set up the members collection if it doesn't exist already
2160
2159
if ( ! funcSymbol . members ) {
2161
- funcSymbol . members = createMap < Symbol > ( ) ;
2160
+ funcSymbol . members = createMap < string , Symbol > ( ) ;
2162
2161
}
2163
2162
2164
2163
// Declare the method/property
@@ -2191,7 +2190,7 @@ namespace ts {
2191
2190
bindAnonymousDeclaration ( node , SymbolFlags . Class , bindingName ) ;
2192
2191
// Add name of class expression into the map for semantic classifier
2193
2192
if ( node . name ) {
2194
- classifiableNames [ node . name . text ] = node . name . text ;
2193
+ classifiableNames . add ( node . name . text ) ;
2195
2194
}
2196
2195
}
2197
2196
@@ -2207,14 +2206,15 @@ namespace ts {
2207
2206
// module might have an exported variable called 'prototype'. We can't allow that as
2208
2207
// that would clash with the built-in 'prototype' for the class.
2209
2208
const prototypeSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Prototype , "prototype" ) ;
2210
- if ( symbol . exports [ prototypeSymbol . name ] ) {
2209
+ const symbolExport = symbol . exports . get ( prototypeSymbol . name ) ;
2210
+ if ( symbolExport ) {
2211
2211
if ( node . name ) {
2212
2212
node . name . parent = node ;
2213
2213
}
2214
- file . bindDiagnostics . push ( createDiagnosticForNode ( symbol . exports [ prototypeSymbol . name ] . declarations [ 0 ] ,
2214
+ file . bindDiagnostics . push ( createDiagnosticForNode ( symbolExport . declarations [ 0 ] ,
2215
2215
Diagnostics . Duplicate_identifier_0 , prototypeSymbol . name ) ) ;
2216
2216
}
2217
- symbol . exports [ prototypeSymbol . name ] = prototypeSymbol ;
2217
+ symbol . exports . set ( prototypeSymbol . name , prototypeSymbol ) ;
2218
2218
prototypeSymbol . parent = symbol ;
2219
2219
}
2220
2220
0 commit comments