Skip to content

Commit

Permalink
fix: align getScriptSnapshot compiler host libFileMap behaviour wit…
Browse files Browse the repository at this point in the history
…h `readFile`
  • Loading branch information
dsherret committed Nov 21, 2021
1 parent 5c0a702 commit 9e84d72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
16 changes: 7 additions & 9 deletions deno/common/ts_morph_common.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions packages/common/src/compiler/createHosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@ export function createHosts(options: CreateHostsOptions) {
},
getScriptSnapshot: fileName => {
const filePath = transactionalFileSystem.getStandardizedAbsolutePath(fileName);
if (!fileExistsSync(filePath)) {
if (libFileMap != null) {
const libFileText = libFileMap.get(filePath);
if (libFileText != null)
return ts.ScriptSnapshot.fromString(libFileText);
}

return undefined;
if (libFileMap != null) {
const libFileText = libFileMap.get(filePath);
if (libFileText != null)
return ts.ScriptSnapshot.fromString(libFileText);
}
return ts.ScriptSnapshot.fromString(sourceFileContainer.addOrGetSourceFileFromFilePathSync(filePath, {

const sourceFile = sourceFileContainer.addOrGetSourceFileFromFilePathSync(filePath, {
markInProject: false,
scriptKind: undefined,
})!.getFullText());
});
return sourceFile ? ts.ScriptSnapshot.fromString(sourceFile.getFullText()) : undefined;
},
getCurrentDirectory: () => transactionalFileSystem.getCurrentDirectory(),
getDefaultLibFileName: options => {
Expand Down

0 comments on commit 9e84d72

Please sign in to comment.