Fix undefined error using getEffectiveTypeRoots
(#19300)
This commit is contained in:
parent
e5f8287e5c
commit
f1abe3c284
2 changed files with 7 additions and 1 deletions
|
@ -212,6 +212,11 @@ namespace Harness.LanguageService {
|
|||
return script ? script.version.toString() : undefined;
|
||||
}
|
||||
|
||||
directoryExists(dirName: string): boolean {
|
||||
const fileEntry = this.virtualFileSystem.traversePath(dirName);
|
||||
return fileEntry && fileEntry.isDirectory();
|
||||
}
|
||||
|
||||
fileExists(fileName: string): boolean {
|
||||
const script = this.getScriptSnapshot(fileName);
|
||||
return script !== undefined;
|
||||
|
|
|
@ -367,7 +367,8 @@ namespace ts.codefix {
|
|||
getCanonicalFileName: (file: string) => string,
|
||||
moduleFileName: string,
|
||||
): string | undefined {
|
||||
return firstDefined(getEffectiveTypeRoots(options, host), unNormalizedTypeRoot => {
|
||||
const roots = getEffectiveTypeRoots(options, host);
|
||||
return roots && firstDefined(roots, unNormalizedTypeRoot => {
|
||||
const typeRoot = toPath(unNormalizedTypeRoot, /*basePath*/ undefined, getCanonicalFileName);
|
||||
if (startsWith(moduleFileName, typeRoot)) {
|
||||
return removeExtensionAndIndexPostFix(moduleFileName.substring(typeRoot.length + 1));
|
||||
|
|
Loading…
Reference in a new issue