Skip to content

Commit 9906b43

Browse files
Guard against undefined relative path.
1 parent 394c842 commit 9906b43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/moduleSpecifiers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,8 @@ namespace ts.moduleSpecifiers {
854854

855855
function getPathRelativeToRootDirs(path: string, rootDirs: readonly string[], getCanonicalFileName: GetCanonicalFileName): string | undefined {
856856
return firstDefined(rootDirs, rootDir => {
857-
const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName)!; // TODO: GH#18217
858-
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
857+
const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
858+
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
859859
});
860860
}
861861

0 commit comments

Comments
 (0)