Skip to content

Commit 2a94899

Browse files
committed
improve ts plus external type cache lookup
1 parent fb3c4a8 commit 2a94899

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/compiler/parser.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ namespace Parser {
16211621
var parseErrorBeforeNextFinishedNode = false;
16221622
/* eslint-enable no-var */
16231623

1624-
const tsPlusExternalTypeCache = new Map<string, Record<string, TsPlusTypeDefinition[]>>()
1624+
const tsPlusExternalTypeCache = new Map<string, Record<string, TsPlusTypeDefinition[]> | undefined>()
16251625
const tsPlusResolvedPathsCache = new Map<string, string[]>()
16261626
const tsPlusResolvedModuleCache = new Map<string, any>()
16271627
let currentTsPlusTypes: TsPlusTypeDefinition[] | null = null;
@@ -1975,18 +1975,18 @@ namespace Parser {
19751975
}
19761976
for (const resolvedPath of resolvedPaths) {
19771977
let json = tsPlusExternalTypeCache.get(resolvedPath);
1978-
if (!json) {
1978+
if (!tsPlusExternalTypeCache.has(resolvedPath)) {
19791979
const text = sys.readFile(resolvedPath);
19801980
if (text) {
19811981
json = JSON.parse(text);
1982-
if (json) { tsPlusExternalTypeCache.set(resolvedPath, json) }
19831982
}
1983+
tsPlusExternalTypeCache.set(resolvedPath, json)
19841984
}
19851985
if (!json) return;
19861986
for (const moduleName in json) {
19871987
const key = `${options.configFilePath ?? fileName}+${moduleName}`;
19881988
let resolvedModule = tsPlusResolvedModuleCache.get(key);
1989-
if (!resolvedModule) {
1989+
if (!tsPlusResolvedModuleCache.has(key)) {
19901990
resolvedModule = resolveModuleName(moduleName, resolvedPath, options, sys).resolvedModule ?? resolveModuleName(moduleName, fileName, options, sys).resolvedModule;
19911991
tsPlusResolvedModuleCache.set(key, resolvedModule);
19921992
}

0 commit comments

Comments
 (0)