diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dd3ab84b36519..4349d256608f9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -563,7 +563,7 @@ namespace ts { const flowLoopNodes: FlowNode[] = []; const flowLoopKeys: string[] = []; const flowLoopTypes: Type[][] = []; - let sharedFlowTypes: MapLike = createDictionaryObject(); + const sharedFlowTypes: Map = createMap(); const potentialThisCollisions: Node[] = []; const potentialNewTargetCollisions: Node[] = []; const awaitedTypeStack: number[] = []; @@ -16063,7 +16063,7 @@ namespace ts { // some getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. const nodeId = `${refKey}@${getFlowNodeId(flow)}`; - const result = sharedFlowTypes[nodeId]; + const result = sharedFlowTypes.get(nodeId); if (result) { flowDepth--; return result; @@ -16132,7 +16132,7 @@ namespace ts { if (flags & FlowFlags.Shared && !isIncomplete(type)) { // Record visited node and the associated type in the cache. const flowId = `${refKey}@${getFlowNodeId(flow)}`; - sharedFlowTypes[flowId] = type; + sharedFlowTypes.set(flowId, type); } flowDepth--; return type; @@ -28956,7 +28956,7 @@ namespace ts { if (skipTypeChecking(node, compilerOptions)) { return; } - sharedFlowTypes = createDictionaryObject(); // We clear this each time we start checking a file so memory usage doesn't grow too much due to flow result caching - we can't really fully clear at any smaller bounds (just erase subsets, if we wanted to track them) + sharedFlowTypes.clear(); // We clear this each time we start checking a file so memory usage doesn't grow too much due to flow result caching - we can't really fully clear at any smaller bounds (just erase subsets, if we wanted to track them) // Grammar checking checkGrammarSourceFile(node); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index bd43496dc4fb2..b99304ddfedca 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -72,7 +72,7 @@ namespace ts { export const emptyArray: never[] = [] as never[]; /** Create a MapLike with good performance. */ - export function createDictionaryObject(): MapLike { + function createDictionaryObject(): MapLike { const map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode.