Guard against undefined relative path.

This commit is contained in:
Daniel Rosenwasser
2022-01-12 21:04:36 +00:00
committed by GitHub
parent 394c8422c2
commit 9906b43ffa

View File

@@ -854,8 +854,8 @@ namespace ts.moduleSpecifiers {
function getPathRelativeToRootDirs(path: string, rootDirs: readonly string[], getCanonicalFileName: GetCanonicalFileName): string | undefined {
return firstDefined(rootDirs, rootDir => {
const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName)!; // TODO: GH#18217
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
});
}