@@ -47,7 +47,7 @@ namespace ts {
47
47
let symbolCount = 0;
48
48
49
49
const emptyArray: any[] = [];
50
- const emptySymbols = new StringMap< Symbol>();
50
+ const emptySymbols = createMap<string, Symbol>();
51
51
52
52
const compilerOptions = host.getCompilerOptions();
53
53
const languageVersion = compilerOptions.target || ScriptTarget.ES3;
@@ -111,10 +111,10 @@ namespace ts {
111
111
};
112
112
113
113
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>();
118
118
const evolvingArrayTypes: EvolvingArrayType[] = [];
119
119
120
120
const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@@ -139,7 +139,7 @@ namespace ts {
139
139
140
140
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
141
141
const emptyGenericType = <GenericType><ObjectType>createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
142
- emptyGenericType.instantiations = new StringMap< TypeReference>();
142
+ emptyGenericType.instantiations = createMap<string, TypeReference>();
143
143
144
144
const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
145
145
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
@@ -155,7 +155,7 @@ namespace ts {
155
155
156
156
const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
157
157
158
- const globals = new StringMap< Symbol>();
158
+ const globals = createMap<string, Symbol>();
159
159
/**
160
160
* List of every ambient module with a "*" wildcard.
161
161
* 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 {
325
325
326
326
let jsxElementType: Type;
327
327
/** Things we lazy load from the JSX namespace */
328
- const jsxTypes = new StringMap< Type>();
328
+ const jsxTypes = createMap<string, Type>();
329
329
const JsxNames = {
330
330
JSX: "JSX",
331
331
IntrinsicElements: "IntrinsicElements",
@@ -336,11 +336,11 @@ namespace ts {
336
336
IntrinsicClassAttributes: "IntrinsicClassAttributes"
337
337
};
338
338
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>();
344
344
345
345
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
346
346
let _displayBuilder: SymbolDisplayBuilder;
@@ -354,7 +354,7 @@ namespace ts {
354
354
ResolvedReturnType
355
355
}
356
356
357
- const builtinGlobals = new StringMap ([[undefinedSymbol.name, undefinedSymbol]]);
357
+ const builtinGlobals = createMap ([[undefinedSymbol.name, undefinedSymbol]]);
358
358
359
359
initializeTypeChecker();
360
360
@@ -437,11 +437,11 @@ namespace ts {
437
437
target.declarations.push(node);
438
438
});
439
439
if (source.members) {
440
- if (!target.members) target.members = new StringMap< Symbol>();
440
+ if (!target.members) target.members = createMap<string, Symbol>();
441
441
mergeSymbolTable(target.members, source.members);
442
442
}
443
443
if (source.exports) {
444
- if (!target.exports) target.exports = new StringMap< Symbol>();
444
+ if (!target.exports) target.exports = createMap<string, Symbol>();
445
445
mergeSymbolTable(target.exports, source.exports);
446
446
}
447
447
recordMergedSymbol(target, source);
@@ -1418,7 +1418,7 @@ namespace ts {
1418
1418
// This provides a name to the module. See the test tests/cases/fourslash/untypedModuleImport.ts
1419
1419
const newSymbol = createSymbol(SymbolFlags.ValueModule, quotedName);
1420
1420
// 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>();
1422
1422
// Cache it so subsequent accesses will return the same module.
1423
1423
globals.set(quotedName, newSymbol);
1424
1424
return newSymbol;
@@ -1531,8 +1531,8 @@ namespace ts {
1531
1531
// All export * declarations are collected in an __export symbol by the binder
1532
1532
const exportStars = symbol.exports.get("__export");
1533
1533
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>();
1536
1536
for (const node of exportStars.declarations) {
1537
1537
const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier);
1538
1538
const exportedSymbols = visit(resolvedModule);
@@ -3237,7 +3237,7 @@ namespace ts {
3237
3237
3238
3238
// Return the type implied by an object binding pattern
3239
3239
function getTypeFromObjectBindingPattern(pattern: ObjectBindingPattern, includePatternInType: boolean, reportErrors: boolean): Type {
3240
- const members = new StringMap< Symbol>();
3240
+ const members = createMap<string, Symbol>();
3241
3241
let hasComputedProperties = false;
3242
3242
forEach(pattern.elements, e => {
3243
3243
const name = e.propertyName || <Identifier>e.name;
@@ -3842,7 +3842,7 @@ namespace ts {
3842
3842
type.typeParameters = concatenate(outerTypeParameters, localTypeParameters);
3843
3843
type.outerTypeParameters = outerTypeParameters;
3844
3844
type.localTypeParameters = localTypeParameters;
3845
- (<GenericType>type).instantiations = new StringMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
3845
+ (<GenericType>type).instantiations = createMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
3846
3846
(<GenericType>type).target = <GenericType>type;
3847
3847
(<GenericType>type).typeArguments = type.typeParameters;
3848
3848
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
@@ -3884,7 +3884,7 @@ namespace ts {
3884
3884
if (typeParameters) {
3885
3885
// Initialize the instantiation cache for generic type aliases. The declared type corresponds to
3886
3886
// 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]]);
3888
3888
}
3889
3889
}
3890
3890
else {
@@ -4572,7 +4572,7 @@ namespace ts {
4572
4572
// these partial properties when identifying discriminant properties, but otherwise they are filtered out
4573
4573
// and do not appear to be present in the union type.
4574
4574
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>());
4576
4576
let property = properties.get(name);
4577
4577
if (!property) {
4578
4578
property = createUnionOrIntersectionProperty(type, name);
@@ -5393,7 +5393,7 @@ namespace ts {
5393
5393
type.typeParameters = typeParameters;
5394
5394
type.outerTypeParameters = undefined;
5395
5395
type.localTypeParameters = typeParameters;
5396
- type.instantiations = new StringMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
5396
+ type.instantiations = createMap ([[getTypeListId(type.typeParameters), <GenericType>type]]);
5397
5397
type.target = <GenericType>type;
5398
5398
type.typeArguments = type.typeParameters;
5399
5399
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
@@ -6906,7 +6906,7 @@ namespace ts {
6906
6906
}
6907
6907
sourceStack[depth] = source;
6908
6908
targetStack[depth] = target;
6909
- maybeStack[depth] = new StringMap ([[id, RelationComparisonResult.Succeeded]]);
6909
+ maybeStack[depth] = createMap ([[id, RelationComparisonResult.Succeeded]]);
6910
6910
depth++;
6911
6911
const saveExpandingFlags = expandingFlags;
6912
6912
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1;
@@ -7591,7 +7591,7 @@ namespace ts {
7591
7591
}
7592
7592
7593
7593
function transformTypeOfMembers(type: Type, f: (propertyType: Type) => Type) {
7594
- const members = new StringMap< Symbol>();
7594
+ const members = createMap<string, Symbol>();
7595
7595
for (const property of getPropertiesOfObjectType(type)) {
7596
7596
const original = getTypeOfSymbol(property);
7597
7597
const updated = f(original);
@@ -7814,7 +7814,7 @@ namespace ts {
7814
7814
let targetStack: Type[];
7815
7815
let depth = 0;
7816
7816
let inferiority = 0;
7817
- const visited = new StringSet ();
7817
+ const visited = createSet ();
7818
7818
inferFromTypes(originalSource, originalTarget);
7819
7819
7820
7820
function isInProcess(source: Type, target: Type) {
@@ -8894,7 +8894,7 @@ namespace ts {
8894
8894
// If we have previously computed the control flow type for the reference at
8895
8895
// this flow loop junction, return the cached type.
8896
8896
const id = getFlowNodeId(flow);
8897
- const cache = flowLoopCaches[id] || (flowLoopCaches[id] = new StringMap< Type>());
8897
+ const cache = flowLoopCaches[id] || (flowLoopCaches[id] = createMap<string, Type>());
8898
8898
if (!key) {
8899
8899
key = getFlowCacheKey(reference);
8900
8900
}
@@ -10594,7 +10594,7 @@ namespace ts {
10594
10594
// Grammar checking
10595
10595
checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
10596
10596
10597
- const propertiesTable = new StringMap< Symbol>();
10597
+ const propertiesTable = createMap<string, Symbol>();
10598
10598
const propertiesArray: Symbol[] = [];
10599
10599
const contextualType = getApparentTypeOfContextualType(node);
10600
10600
const contextualTypeHasPattern = contextualType && contextualType.pattern &&
@@ -11145,7 +11145,7 @@ namespace ts {
11145
11145
11146
11146
const targetAttributesType = getJsxElementAttributesType(node);
11147
11147
11148
- const nameTable = new StringSet ();
11148
+ const nameTable = createSet ();
11149
11149
// Process this array in right-to-left order so we know which
11150
11150
// attributes (mostly from spreads) are being overwritten and
11151
11151
// thus should have their types ignored
@@ -14622,8 +14622,8 @@ namespace ts {
14622
14622
Property = Getter | Setter
14623
14623
}
14624
14624
14625
- const instanceNames = new StringMap< Accessor>();
14626
- const staticNames = new StringMap< Accessor>();
14625
+ const instanceNames = createMap<string, Accessor>();
14626
+ const staticNames = createMap<string, Accessor>();
14627
14627
for (const member of node.members) {
14628
14628
if (member.kind === SyntaxKind.Constructor) {
14629
14629
for (const param of (member as ConstructorDeclaration).parameters) {
@@ -14672,7 +14672,7 @@ namespace ts {
14672
14672
}
14673
14673
14674
14674
function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) {
14675
- const names = new StringSet ();
14675
+ const names = createSet ();
14676
14676
for (const member of node.members) {
14677
14677
if (member.kind == SyntaxKind.PropertySignature) {
14678
14678
let memberName: string;
@@ -18490,7 +18490,7 @@ namespace ts {
18490
18490
}
18491
18491
18492
18492
function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] {
18493
- const symbols = new StringMap< Symbol>();
18493
+ const symbols = createMap<string, Symbol>();
18494
18494
let memberFlags: ModifierFlags = ModifierFlags.None;
18495
18495
18496
18496
if (isInsideWithStatementBody(location)) {
@@ -20315,7 +20315,7 @@ namespace ts {
20315
20315
}
20316
20316
20317
20317
function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) {
20318
- const seen = new StringMap< SymbolFlags>();
20318
+ const seen = createMap<string, SymbolFlags>();
20319
20319
const Property = 1;
20320
20320
const GetAccessor = 2;
20321
20321
const SetAccessor = 4;
@@ -20402,7 +20402,7 @@ namespace ts {
20402
20402
}
20403
20403
20404
20404
function checkGrammarJsxElement(node: JsxOpeningLikeElement) {
20405
- const seen = new StringSet ();
20405
+ const seen = createSet ();
20406
20406
for (const attr of node.attributes) {
20407
20407
if (attr.kind === SyntaxKind.JsxSpreadAttribute) {
20408
20408
continue;
0 commit comments