Skip to content

Commit 0426e48

Browse files
Fix crash when host.getSourceFile returns undefined (microsoft#37373)
Another day, another incorrect non-null assertion Fixes microsoft#37368
1 parent f06f809 commit 0426e48

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/compiler/checker.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -35645,10 +35645,12 @@ namespace ts {
3564535645
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
3564635646
return;
3564735647
}
35648-
const file = host.getSourceFile(resolvedDirective.resolvedFileName)!;
35649-
// Add the transitive closure of path references loaded by this file (as long as they are not)
35650-
// part of an existing type reference.
35651-
addReferencedFilesToTypeDirective(file, key);
35648+
const file = host.getSourceFile(resolvedDirective.resolvedFileName);
35649+
if (file) {
35650+
// Add the transitive closure of path references loaded by this file (as long as they are not)
35651+
// part of an existing type reference.
35652+
addReferencedFilesToTypeDirective(file, key);
35653+
}
3565235654
});
3565335655
}
3565435656

0 commit comments

Comments
 (0)