From e64dbabab87dc474f38e1693331b475d27cbd429 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 6 Nov 2021 09:33:40 +0000 Subject: [PATCH] More removals. --- src/compiler/checker.ts | 24 ++++++---------------- src/compiler/factory/nodeFactory.ts | 2 +- src/compiler/program.ts | 4 ---- src/compiler/transformers/es5.ts | 2 +- src/compiler/transformers/module/module.ts | 6 +++--- src/compiler/types.ts | 2 +- 6 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 40f035abeda..61c2d1568bb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -288,14 +288,6 @@ namespace ts { return result; } - export function getNodeIdOrDefault(node: Node): number { - return idCache.get(node) || 0; - } - - export function setNodeIdForStrangeRedirect(node: Node, id: number): void { - idCache.set(node, id); - } - export function getSymbolId(symbol: Symbol): SymbolId { if (!symbol.id) { symbol.id = nextSymbolId; @@ -971,7 +963,7 @@ namespace ts { let flowInvocationCount = 0; let lastFlowNode: FlowNode | undefined; let lastFlowNodeReachable: boolean; - let flowTypeCache: Type[] | undefined; + let flowTypeCache: ESMap | undefined; const emptyStringType = getStringLiteralType(""); const zeroType = getNumberLiteralType(0); @@ -3899,10 +3891,9 @@ namespace ts { function getAlternativeContainingModules(symbol: Symbol, enclosingDeclaration: Node): Symbol[] { const containingFile = getSourceFileOfNode(enclosingDeclaration); - const id = getNodeId(containingFile); const links = getSymbolLinks(symbol); let results: Symbol[] | undefined; - if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) { + if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(containingFile))) { return results; } if (containingFile && containingFile.imports) { @@ -3916,7 +3907,7 @@ namespace ts { results = append(results, resolvedModule); } if (length(results)) { - (links.extendedContainersByFile || (links.extendedContainersByFile = new Map())).set(id, results!); + (links.extendedContainersByFile ||= new Map()).set(containingFile, results!); return results!; } } @@ -33799,7 +33790,7 @@ namespace ts { } // If a type has been cached for the node, return it. if (node.flags & NodeFlags.TypeCached && flowTypeCache) { - const cachedType = flowTypeCache[getNodeId(node)]; + const cachedType = flowTypeCache.get(node); if (cachedType) { return cachedType; } @@ -33808,8 +33799,8 @@ namespace ts { const type = checkExpression(node); // If control flow analysis was required to determine the type, it is worth caching. if (flowInvocationCount !== startInvocationCount) { - const cache = flowTypeCache || (flowTypeCache = []); - cache[getNodeId(node)] = type; + const cache = (flowTypeCache ||= new Map()); + cache.set(node, type); setNodeFlags(node, node.flags | NodeFlags.TypeCached); } return type; @@ -41612,9 +41603,6 @@ namespace ts { } function getNodeCheckFlags(node: Node): NodeCheckFlags { - // TODO: probably not meaningful, right? - // const nodeId = getNodeIdOrDefault(node); - // if (nodeId < 0 || nodeId >= nodeLinks.length) return 0; return nodeLinks.get(node)?.flags || 0; } diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index f41fea50eda..63b241dc9e5 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -5339,7 +5339,7 @@ namespace ts { } function flattenCommaElements(node: Expression): Expression | readonly Expression[] { - if (nodeIsSynthesized(node) && !isParseTreeNode(node) && !node.original && !node.emitNode && !getNodeIdOrDefault(node)) { + if (nodeIsSynthesized(node) && !isParseTreeNode(node) && !node.original && !node.emitNode) { if (isCommaListExpression(node)) { return node.elements; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 65b5297c021..12fbb067ddc 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2592,10 +2592,6 @@ namespace ts { redirect.redirectInfo = { redirectTarget, unredirected }; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { - id: { - get(this: SourceFile) { return getNodeIdOrDefault(this.redirectInfo!.redirectTarget); }, - set(this: SourceFile, value: number) { setNodeIdForStrangeRedirect(this.redirectInfo!.redirectTarget, value); }, - }, symbol: { get(this: SourceFile) { return this.redirectInfo!.redirectTarget.symbol; }, set(this: SourceFile, value: SourceFile["symbol"]) { this.redirectInfo!.redirectTarget.symbol = value; }, diff --git a/src/compiler/transformers/es5.ts b/src/compiler/transformers/es5.ts index ade270edf17..9dc69f21475 100644 --- a/src/compiler/transformers/es5.ts +++ b/src/compiler/transformers/es5.ts @@ -64,7 +64,7 @@ namespace ts { */ function onSubstituteNode(hint: EmitHint, node: Node) { // TODO: do we need to check for a Node ID here? - if (getNodeIdOrDefault(node) && noSubstitution?.has(node)) { + if (noSubstitution?.has(node)) { return previousOnSubstituteNode(hint, node); } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 496562c3922..df3cc9b95a3 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -698,7 +698,7 @@ namespace ts { } if (temp) { - noSubstitution.add(expression);; + noSubstitution.add(expression); expression = factory.createComma(expression, temp); setTextRange(expression, node); } @@ -1852,7 +1852,7 @@ namespace ts { function substituteCallExpression(node: CallExpression) { if (isIdentifier(node.expression)) { const expression = substituteExpressionIdentifier(node.expression); - noSubstitution.add(expression);; + noSubstitution.add(expression); if (!isIdentifier(expression)) { return addEmitFlags( factory.updateCallExpression(node, @@ -1962,7 +1962,7 @@ namespace ts { let expression: Expression = node; for (const exportName of exportedNames) { // Mark the node to prevent triggering this rule again. - noSubstitution.add(expression);; + noSubstitution.add(expression); expression = createExportExpression(exportName, expression, /*location*/ node); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index bc479ec932c..7f843c10365 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4945,7 +4945,7 @@ namespace ts { lateSymbol?: Symbol; // Late-bound symbol for a computed property specifierCache?: ESMap; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in - extendedContainersByFile?: ESMap; // Containers (other than the parent) which this symbol is aliased in + extendedContainersByFile?: ESMap; // Containers (other than the parent) which this symbol is aliased in variances?: VarianceFlags[]; // Alias symbol type argument variance cache deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type deferralParent?: Type; // Source union/intersection of a deferred type