@@ -288,14 +288,6 @@ namespace ts {
288288 return result;
289289 }
290290
291- export function getNodeIdOrDefault(node: Node): number {
292- return idCache.get(node) || 0;
293- }
294-
295- export function setNodeIdForStrangeRedirect(node: Node, id: number): void {
296- idCache.set(node, id);
297- }
298-
299291 export function getSymbolId(symbol: Symbol): SymbolId {
300292 if (!symbol.id) {
301293 symbol.id = nextSymbolId;
@@ -971,7 +963,7 @@ namespace ts {
971963 let flowInvocationCount = 0;
972964 let lastFlowNode: FlowNode | undefined;
973965 let lastFlowNodeReachable: boolean;
974- let flowTypeCache: Type[] | undefined;
966+ let flowTypeCache: ESMap<Node, Type> | undefined;
975967
976968 const emptyStringType = getStringLiteralType("");
977969 const zeroType = getNumberLiteralType(0);
@@ -3899,10 +3891,9 @@ namespace ts {
38993891
39003892 function getAlternativeContainingModules(symbol: Symbol, enclosingDeclaration: Node): Symbol[] {
39013893 const containingFile = getSourceFileOfNode(enclosingDeclaration);
3902- const id = getNodeId(containingFile);
39033894 const links = getSymbolLinks(symbol);
39043895 let results: Symbol[] | undefined;
3905- if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id ))) {
3896+ if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(containingFile ))) {
39063897 return results;
39073898 }
39083899 if (containingFile && containingFile.imports) {
@@ -3916,7 +3907,7 @@ namespace ts {
39163907 results = append(results, resolvedModule);
39173908 }
39183909 if (length(results)) {
3919- (links.extendedContainersByFile || (links.extendedContainersByFile = new Map())) .set(id , results!);
3910+ (links.extendedContainersByFile ||= new Map()).set(containingFile , results!);
39203911 return results!;
39213912 }
39223913 }
@@ -33799,7 +33790,7 @@ namespace ts {
3379933790 }
3380033791 // If a type has been cached for the node, return it.
3380133792 if (node.flags & NodeFlags.TypeCached && flowTypeCache) {
33802- const cachedType = flowTypeCache[getNodeId (node)] ;
33793+ const cachedType = flowTypeCache.get (node);
3380333794 if (cachedType) {
3380433795 return cachedType;
3380533796 }
@@ -33808,8 +33799,8 @@ namespace ts {
3380833799 const type = checkExpression(node);
3380933800 // If control flow analysis was required to determine the type, it is worth caching.
3381033801 if (flowInvocationCount !== startInvocationCount) {
33811- const cache = flowTypeCache || (flowTypeCache = [] );
33812- cache[getNodeId (node)] = type;
33802+ const cache = ( flowTypeCache ||= new Map<Node, Type>() );
33803+ cache.set (node, type) ;
3381333804 setNodeFlags(node, node.flags | NodeFlags.TypeCached);
3381433805 }
3381533806 return type;
@@ -41612,9 +41603,6 @@ namespace ts {
4161241603 }
4161341604
4161441605 function getNodeCheckFlags(node: Node): NodeCheckFlags {
41615- // TODO: probably not meaningful, right?
41616- // const nodeId = getNodeIdOrDefault(node);
41617- // if (nodeId < 0 || nodeId >= nodeLinks.length) return 0;
4161841606 return nodeLinks.get(node)?.flags || 0;
4161941607 }
4162041608
0 commit comments