From 9906b43ffa5263b97758947d54d722ff6164d2a2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 12 Jan 2022 21:04:36 +0000 Subject: [PATCH] Guard against undefined relative path. --- src/compiler/moduleSpecifiers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index c17dfeabcf1..db0b49f4436 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -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; }); }