@@ -47,7 +47,7 @@ namespace ts {
4747 let symbolCount = 0;
4848
4949 const emptyArray: any[] = [];
50- const emptySymbols = new StringMap< Symbol>();
50+ const emptySymbols = createMap<string, Symbol>();
5151
5252 const compilerOptions = host.getCompilerOptions();
5353 const languageVersion = compilerOptions.target || ScriptTarget.ES3;
@@ -111,10 +111,10 @@ namespace ts {
111111 };
112112
113113 const tupleTypes: GenericType[] = [];
114- const unionTypes = new StringMap< UnionType>();
115- const intersectionTypes = new StringMap< IntersectionType>();
116- const stringLiteralTypes = new StringMap< LiteralType>();
117- const numericLiteralTypes = new StringMap< LiteralType>();
114+ const unionTypes = createMap<string, UnionType>();
115+ const intersectionTypes = createMap<string, IntersectionType>();
116+ const stringLiteralTypes = createMap<string, LiteralType>();
117+ const numericLiteralTypes = createMap<string, LiteralType>();
118118 const evolvingArrayTypes: EvolvingArrayType[] = [];
119119
120120 const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@@ -139,7 +139,7 @@ namespace ts {
139139
140140 const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
141141 const emptyGenericType = <GenericType><ObjectType>createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
142- emptyGenericType.instantiations = new StringMap< TypeReference>();
142+ emptyGenericType.instantiations = createMap<string, TypeReference>();
143143
144144 const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
145145 // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
@@ -155,7 +155,7 @@ namespace ts {
155155
156156 const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
157157
158- const globals = new StringMap< Symbol>();
158+ const globals = createMap<string, Symbol>();
159159 /**
160160 * List of every ambient module with a "*" wildcard.
161161 * Unlike other ambient modules, these can't be stored in `globals` because symbol tables only deal with exact matches.
@@ -325,7 +325,7 @@ namespace ts {
325325
326326 let jsxElementType: Type;
327327 /** Things we lazy load from the JSX namespace */
328- const jsxTypes = new StringMap< Type>();
328+ const jsxTypes = createMap<string, Type>();
329329 const JsxNames = {
330330 JSX: "JSX",
331331 IntrinsicElements: "IntrinsicElements",
@@ -336,11 +336,11 @@ namespace ts {
336336 IntrinsicClassAttributes: "IntrinsicClassAttributes"
337337 };
338338
339- const subtypeRelation = new StringMap< RelationComparisonResult>();
340- const assignableRelation = new StringMap< RelationComparisonResult>();
341- const comparableRelation = new StringMap< RelationComparisonResult>();
342- const identityRelation = new StringMap< RelationComparisonResult>();
343- const enumRelation = new StringMap< boolean>();
339+ const subtypeRelation = createMap<string, RelationComparisonResult>();
340+ const assignableRelation = createMap<string, RelationComparisonResult>();
341+ const comparableRelation = createMap<string, RelationComparisonResult>();
342+ const identityRelation = createMap<string, RelationComparisonResult>();
343+ const enumRelation = createMap<string, boolean>();
344344
345345 // This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
346346 let _displayBuilder: SymbolDisplayBuilder;
@@ -354,7 +354,7 @@ namespace ts {
354354 ResolvedReturnType
355355 }
356356
357- const builtinGlobals = new StringMap ([[undefinedSymbol.name, undefinedSymbol]]);
357+ const builtinGlobals = createMap ([[undefinedSymbol.name, undefinedSymbol]]);
358358
359359 initializeTypeChecker();
360360
@@ -437,11 +437,11 @@ namespace ts {
437437 target.declarations.push(node);
438438 });
439439 if (source.members) {
440- if (!target.members) target.members = new StringMap< Symbol>();
440+ if (!target.members) target.members = createMap<string, Symbol>();
441441 mergeSymbolTable(target.members, source.members);
442442 }
443443 if (source.exports) {
444- if (!target.exports) target.exports = new StringMap< Symbol>();
444+ if (!target.exports) target.exports = createMap<string, Symbol>();
445445 mergeSymbolTable(target.exports, source.exports);
446446 }
447447 recordMergedSymbol(target, source);
@@ -1418,7 +1418,7 @@ namespace ts {
14181418 // This provides a name to the module. See the test tests/cases/fourslash/untypedModuleImport.ts
14191419 const newSymbol = createSymbol(SymbolFlags.ValueModule, quotedName);
14201420 // Module symbols are expected to have 'exports', although since this is an untyped module it can be empty.
1421- newSymbol.exports = new StringMap< Symbol>();
1421+ newSymbol.exports = createMap<string, Symbol>();
14221422 // Cache it so subsequent accesses will return the same module.
14231423 globals.set(quotedName, newSymbol);
14241424 return newSymbol;
@@ -1531,8 +1531,8 @@ namespace ts {
15311531 // All export * declarations are collected in an __export symbol by the binder
15321532 const exportStars = symbol.exports.get("__export");
15331533 if (exportStars) {
1534- const nestedSymbols = new StringMap< Symbol>();
1535- const lookupTable = new StringMap< ExportCollisionTracker>();
1534+ const nestedSymbols = createMap<string, Symbol>();
1535+ const lookupTable = createMap<string, ExportCollisionTracker>();
15361536 for (const node of exportStars.declarations) {
15371537 const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier);
15381538 const exportedSymbols = visit(resolvedModule);
@@ -3237,7 +3237,7 @@ namespace ts {
32373237
32383238 // Return the type implied by an object binding pattern
32393239 function getTypeFromObjectBindingPattern(pattern: ObjectBindingPattern, includePatternInType: boolean, reportErrors: boolean): Type {
3240- const members = new StringMap< Symbol>();
3240+ const members = createMap<string, Symbol>();
32413241 let hasComputedProperties = false;
32423242 forEach(pattern.elements, e => {
32433243 const name = e.propertyName || <Identifier>e.name;
@@ -3842,7 +3842,7 @@ namespace ts {
38423842 type.typeParameters = concatenate(outerTypeParameters, localTypeParameters);
38433843 type.outerTypeParameters = outerTypeParameters;
38443844 type.localTypeParameters = localTypeParameters;
3845- (<GenericType>type).instantiations = new StringMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
3845+ (<GenericType>type).instantiations = createMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
38463846 (<GenericType>type).target = <GenericType>type;
38473847 (<GenericType>type).typeArguments = type.typeParameters;
38483848 type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
@@ -3884,7 +3884,7 @@ namespace ts {
38843884 if (typeParameters) {
38853885 // Initialize the instantiation cache for generic type aliases. The declared type corresponds to
38863886 // an instantiation of the type alias with the type parameters supplied as type arguments.
3887- links.instantiations = new StringMap ([[getTypeListId(links.typeParameters), type]]);
3887+ links.instantiations = createMap ([[getTypeListId(links.typeParameters), type]]);
38883888 }
38893889 }
38903890 else {
@@ -4572,7 +4572,7 @@ namespace ts {
45724572 // these partial properties when identifying discriminant properties, but otherwise they are filtered out
45734573 // and do not appear to be present in the union type.
45744574 function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: string): Symbol {
4575- const properties = type.resolvedProperties || (type.resolvedProperties = new StringMap< Symbol>());
4575+ const properties = type.resolvedProperties || (type.resolvedProperties = createMap<string, Symbol>());
45764576 let property = properties.get(name);
45774577 if (!property) {
45784578 property = createUnionOrIntersectionProperty(type, name);
@@ -5393,7 +5393,7 @@ namespace ts {
53935393 type.typeParameters = typeParameters;
53945394 type.outerTypeParameters = undefined;
53955395 type.localTypeParameters = typeParameters;
5396- type.instantiations = new StringMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
5396+ type.instantiations = createMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
53975397 type.target = <GenericType>type;
53985398 type.typeArguments = type.typeParameters;
53995399 type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
@@ -6906,7 +6906,7 @@ namespace ts {
69066906 }
69076907 sourceStack[depth] = source;
69086908 targetStack[depth] = target;
6909- maybeStack[depth] = new StringMap ([[id, RelationComparisonResult.Succeeded]]);
6909+ maybeStack[depth] = createMap ([[id, RelationComparisonResult.Succeeded]]);
69106910 depth++;
69116911 const saveExpandingFlags = expandingFlags;
69126912 if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1;
@@ -7591,7 +7591,7 @@ namespace ts {
75917591 }
75927592
75937593 function transformTypeOfMembers(type: Type, f: (propertyType: Type) => Type) {
7594- const members = new StringMap< Symbol>();
7594+ const members = createMap<string, Symbol>();
75957595 for (const property of getPropertiesOfObjectType(type)) {
75967596 const original = getTypeOfSymbol(property);
75977597 const updated = f(original);
@@ -7814,7 +7814,7 @@ namespace ts {
78147814 let targetStack: Type[];
78157815 let depth = 0;
78167816 let inferiority = 0;
7817- const visited = new StringSet ();
7817+ const visited = createSet ();
78187818 inferFromTypes(originalSource, originalTarget);
78197819
78207820 function isInProcess(source: Type, target: Type) {
@@ -8894,7 +8894,7 @@ namespace ts {
88948894 // If we have previously computed the control flow type for the reference at
88958895 // this flow loop junction, return the cached type.
88968896 const id = getFlowNodeId(flow);
8897- const cache = flowLoopCaches[id] || (flowLoopCaches[id] = new StringMap< Type>());
8897+ const cache = flowLoopCaches[id] || (flowLoopCaches[id] = createMap<string, Type>());
88988898 if (!key) {
88998899 key = getFlowCacheKey(reference);
89008900 }
@@ -10594,7 +10594,7 @@ namespace ts {
1059410594 // Grammar checking
1059510595 checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
1059610596
10597- const propertiesTable = new StringMap< Symbol>();
10597+ const propertiesTable = createMap<string, Symbol>();
1059810598 const propertiesArray: Symbol[] = [];
1059910599 const contextualType = getApparentTypeOfContextualType(node);
1060010600 const contextualTypeHasPattern = contextualType && contextualType.pattern &&
@@ -11145,7 +11145,7 @@ namespace ts {
1114511145
1114611146 const targetAttributesType = getJsxElementAttributesType(node);
1114711147
11148- const nameTable = new StringSet ();
11148+ const nameTable = createSet ();
1114911149 // Process this array in right-to-left order so we know which
1115011150 // attributes (mostly from spreads) are being overwritten and
1115111151 // thus should have their types ignored
@@ -14622,8 +14622,8 @@ namespace ts {
1462214622 Property = Getter | Setter
1462314623 }
1462414624
14625- const instanceNames = new StringMap< Accessor>();
14626- const staticNames = new StringMap< Accessor>();
14625+ const instanceNames = createMap<string, Accessor>();
14626+ const staticNames = createMap<string, Accessor>();
1462714627 for (const member of node.members) {
1462814628 if (member.kind === SyntaxKind.Constructor) {
1462914629 for (const param of (member as ConstructorDeclaration).parameters) {
@@ -14672,7 +14672,7 @@ namespace ts {
1467214672 }
1467314673
1467414674 function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) {
14675- const names = new StringSet ();
14675+ const names = createSet ();
1467614676 for (const member of node.members) {
1467714677 if (member.kind == SyntaxKind.PropertySignature) {
1467814678 let memberName: string;
@@ -18490,7 +18490,7 @@ namespace ts {
1849018490 }
1849118491
1849218492 function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] {
18493- const symbols = new StringMap< Symbol>();
18493+ const symbols = createMap<string, Symbol>();
1849418494 let memberFlags: ModifierFlags = ModifierFlags.None;
1849518495
1849618496 if (isInsideWithStatementBody(location)) {
@@ -20315,7 +20315,7 @@ namespace ts {
2031520315 }
2031620316
2031720317 function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) {
20318- const seen = new StringMap< SymbolFlags>();
20318+ const seen = createMap<string, SymbolFlags>();
2031920319 const Property = 1;
2032020320 const GetAccessor = 2;
2032120321 const SetAccessor = 4;
@@ -20402,7 +20402,7 @@ namespace ts {
2040220402 }
2040320403
2040420404 function checkGrammarJsxElement(node: JsxOpeningLikeElement) {
20405- const seen = new StringSet ();
20405+ const seen = createSet ();
2040620406 for (const attr of node.attributes) {
2040720407 if (attr.kind === SyntaxKind.JsxSpreadAttribute) {
2040820408 continue;
0 commit comments