From ced38f315e84cc481e4ff93b7ab613bd18813ef7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 9 Nov 2021 00:34:36 +0000 Subject: [PATCH] Same trick for `symbol.id`, and always set it to 0. --- src/compiler/checker.ts | 7 ++++--- src/compiler/types.ts | 2 +- src/compiler/utilities.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2dde040f501..4ce54bbcabe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -287,12 +287,13 @@ namespace ts { } export function getSymbolId(symbol: Symbol): SymbolId { - if (!symbol.id) { - symbol.id = nextSymbolId; + let id = symbol.id; + if (!id) { + symbol.id = id = nextSymbolId; nextSymbolId++; } - return symbol.id; + return id; } export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7e3a236036a..35e5d68d9b8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4900,7 +4900,7 @@ namespace ts { members?: SymbolTable; // Class, interface or object literal instance members exports?: SymbolTable; // Module exports globalExports?: SymbolTable; // Conditional global UMD exports - /* @internal */ id?: SymbolId; // Unique id (used to look up SymbolLinks) + /* @internal */ id: SymbolId; // Unique id (used to look up SymbolLinks) /* @internal */ mergeId?: number; // Merge id (used to look up merged symbol) /* @internal */ parent?: Symbol; // Parent symbol /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8caba5b205a..1eb07d33288 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -5798,7 +5798,7 @@ namespace ts { this.escapedName = name; this.declarations = undefined; this.valueDeclaration = undefined; - this.id = undefined; + this.id = 0; this.mergeId = undefined; this.parent = undefined; }