Skip to content

Commit bdb2698

Browse files
committed
Take a riskier approach to removing host.fileExists
1 parent 3793795 commit bdb2698

File tree

3 files changed

+1
-8
lines changed

3 files changed

+1
-8
lines changed

src/compiler/moduleSpecifiers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ function tryGetModuleNameFromRootDirs(rootDirs: readonly string[], moduleFileNam
996996
}
997997

998998
function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCanonicalFileName, canonicalSourceDirectory }: Info, importingSourceFile: SourceFile, host: ModuleSpecifierResolutionHost, options: CompilerOptions, userPreferences: UserPreferences, packageNameOnly?: boolean, overrideMode?: ResolutionMode): string | undefined {
999-
if (host.fileExists === undefined || !host.readFile) {
999+
if (!host.readFile) {
10001000
return undefined;
10011001
}
10021002
const parts: NodeModulePathParts = getNodeModulePathParts(path)!;
@@ -1145,7 +1145,6 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan
11451145
}
11461146

11471147
function tryGetAnyFileFromPath(host: ModuleSpecifierResolutionHost, path: string) {
1148-
if (host.fileExists === undefined) return;
11491148
// We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
11501149
const extensions = flatten(getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: ScriptKind.JSON }]));
11511150
for (const e of extensions) {

src/services/stringCompletions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,8 +1182,6 @@ function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: Com
11821182
}
11831183

11841184
function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string): readonly string[] {
1185-
if (!host.readFile || !host.fileExists) return emptyArray;
1186-
11871185
const result: string[] = [];
11881186
for (const packageJson of findPackageJsons(scriptPath, host)) {
11891187
const contents = readJson(packageJson, host as { readFile: (filename: string) => string | undefined; }); // Cast to assert that readFile is defined

src/services/utilities.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3670,10 +3670,6 @@ export function findPackageJson(directory: string, host: LanguageServiceHost): s
36703670

36713671
/** @internal */
36723672
export function getPackageJsonsVisibleToFile(fileName: string, host: LanguageServiceHost): readonly ProjectPackageJsonInfo[] {
3673-
if (!host.fileExists) {
3674-
return [];
3675-
}
3676-
36773673
const packageJsons: ProjectPackageJsonInfo[] = [];
36783674
forEachAncestorDirectory(getDirectoryPath(fileName), ancestor => {
36793675
const packageJsonFileName = combinePaths(ancestor, "package.json");

0 commit comments

Comments
 (0)