From 5c98b9cfc1f275877d8d57a60f8f28a5c8d08157 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 28 Sep 2022 10:04:51 -0700 Subject: [PATCH] Revert the fix --- src/compiler/program.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b6011e83185f5..74abd84b43665 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -171,7 +171,7 @@ namespace ts { const readFileCache = new Map(); const fileExistsCache = new Map(); const directoryExistsCache = new Map(); - const sourceFileCache = new Map>(); + const sourceFileCache = new Map(); const readFileWithCache = (fileName: string): string | undefined => { const key = toPath(fileName); @@ -196,16 +196,14 @@ namespace ts { return setReadFileCache(key, fileName); }; - const getSourceFileWithCache: CompilerHost["getSourceFile"] | undefined = getSourceFile ? (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => { + const getSourceFileWithCache: CompilerHost["getSourceFile"] | undefined = getSourceFile ? (fileName, languageVersion, onError, shouldCreateNewSourceFile) => { const key = toPath(fileName); - const impliedNodeFormat: SourceFile["impliedNodeFormat"] = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : undefined; - const forPath = sourceFileCache.get(key); - const value = forPath?.get(impliedNodeFormat); + const value = sourceFileCache.get(key); if (value) return value; - const sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile); + const sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); if (sourceFile && (isDeclarationFileName(fileName) || fileExtensionIs(fileName, Extension.Json))) { - sourceFileCache.set(key, (forPath || new Map()).set(impliedNodeFormat, sourceFile)); + sourceFileCache.set(key, sourceFile); } return sourceFile; } : undefined; @@ -230,8 +228,7 @@ namespace ts { sourceFileCache.delete(key); } else if (getSourceFileWithCache) { - const sourceFileMap = sourceFileCache.get(key); - const sourceFile = sourceFileMap && firstDefinedIterator(sourceFileMap.values(), identity); + const sourceFile = sourceFileCache.get(key); if (sourceFile && sourceFile.text !== data) { sourceFileCache.delete(key); }