Skip to content

Commit 55b8e4f

Browse files
committed
Handle "" correctly when cacheing file text
1 parent 604af5c commit 55b8e4f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/program.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,18 @@ namespace ts {
230230
const readFileWithCache = (fileName: string): string | undefined => {
231231
const key = toPath(fileName);
232232
const value = readFileCache.get(key);
233-
if (value !== undefined) return value || undefined;
233+
if (value !== undefined) return value !== false ? value : undefined;
234234
return setReadFileCache(key, fileName);
235235
};
236236
const setReadFileCache = (key: Path, fileName: string) => {
237237
const newValue = originalReadFile.call(host, fileName);
238-
readFileCache.set(key, newValue || false);
238+
readFileCache.set(key, newValue !== undefined ? newValue : false);
239239
return newValue;
240240
};
241241
host.readFile = fileName => {
242242
const key = toPath(fileName);
243243
const value = readFileCache.get(key);
244-
if (value !== undefined) return value || undefined; // could be .d.ts from output
244+
if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output
245245
if (!fileExtensionIs(fileName, Extension.Json)) {
246246
return originalReadFile.call(host, fileName);
247247
}

0 commit comments

Comments
 (0)