mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Fix undefined error using getEffectiveTypeRoots (#19300)
This commit is contained in:
1 parent
e5f8287e5c
commit
f1abe3c284
2 files changed
+7
-1
No files matched your search
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user