Skip to content

Commit

Permalink
improve ts plus external type cache lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
patroza committed Oct 20, 2023
1 parent f8d557e commit 600aa4a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/compiler/parser.ts
Expand Up @@ -1621,7 +1621,7 @@ namespace Parser {
var parseErrorBeforeNextFinishedNode = false;
/* eslint-enable no-var */

const tsPlusExternalTypeCache = new Map<string, Record<string, TsPlusTypeDefinition[]>>()
const tsPlusExternalTypeCache = new Map<string, Record<string, TsPlusTypeDefinition[]> | undefined>()
const tsPlusResolvedPathsCache = new Map<string, string[]>()
const tsPlusResolvedModuleCache = new Map<string, any>()
let currentTsPlusTypes: TsPlusTypeDefinition[] | null = null;
Expand Down Expand Up @@ -1975,18 +1975,18 @@ namespace Parser {
}
for (const resolvedPath of resolvedPaths) {
let json = tsPlusExternalTypeCache.get(resolvedPath);
if (!json) {
if (!tsPlusExternalTypeCache.has(resolvedPath)) {
const text = sys.readFile(resolvedPath);
if (text) {
json = JSON.parse(text);
if (json) { tsPlusExternalTypeCache.set(resolvedPath, json) }
}
tsPlusExternalTypeCache.set(resolvedPath, json)
}
if (!json) return;
for (const moduleName in json) {
const key = `${options.configFilePath ?? fileName}+${moduleName}`;
let resolvedModule = tsPlusResolvedModuleCache.get(key);
if (!resolvedModule) {
if (!tsPlusResolvedModuleCache.has(key)) {
resolvedModule = resolveModuleName(moduleName, resolvedPath, options, sys).resolvedModule ?? resolveModuleName(moduleName, fileName, options, sys).resolvedModule;
tsPlusResolvedModuleCache.set(key, resolvedModule);
}
Expand Down

0 comments on commit 600aa4a

Please sign in to comment.