Skip to content

Commit deb492a

Browse files
committed
Fix issue with caching source files
1 parent 4e6bc59 commit deb492a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

js/compiler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ class Host implements ts.CompilerHost {
264264
const sourceFile = fetchSourceFile(specifier, referrer);
265265
assert(sourceFile.moduleName != null);
266266
const { moduleName } = sourceFile;
267-
assert(!(moduleName! in this._sourceFileCache));
268-
this._sourceFileCache[moduleName!] = sourceFile;
267+
if (!(moduleName! in this._sourceFileCache)) {
268+
this._sourceFileCache[moduleName!] = sourceFile;
269+
}
269270
return sourceFile;
270271
}
271272

js/type_directives.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function parseTypeDirectives(
4949
return;
5050
}
5151

52+
// collect all the directives in the file and their start and end positions
5253
const directives: DirectiveInfo[] = [];
5354
let maybeMatch: RegExpExecArray | null = null;
5455
while ((maybeMatch = typeDirectiveRegEx.exec(sourceCode))) {
@@ -64,6 +65,8 @@ export function parseTypeDirectives(
6465
return;
6566
}
6667

68+
// work from the last directive backwards for any `import`/`export` statements
69+
// adding their module specifiers to
6770
directives.reverse();
6871
const directiveRecords: Record<string, string> = {};
6972
for (const { path, start, end } of directives) {

0 commit comments

Comments
 (0)