From 1bf49f30ff774329664d88a3c0fe1b72abf72efe Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 16 Aug 2016 09:01:11 -0700 Subject: [PATCH] Quick fix error where calling `host.fileExists` caused vscode to stop services --- src/compiler/program.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 767fcb488bbf9..9b5d49d3c4580 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1078,8 +1078,15 @@ namespace ts { for (const typeDirectivePath of host.getDirectories(root)) { const normalized = normalizePath(typeDirectivePath); const packageJsonPath = pathToPackageJson(combinePaths(root, normalized)); + let packageJsonExists = false; + try { + packageJsonExists = host.fileExists(packageJsonPath); + } + catch (e) { + // See GH#10366 + } // tslint:disable-next-line:no-null-keyword - const isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + const isNotNeededPackage = packageJsonExists && readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { // Return just the type directive names result.push(getBaseFileName(normalized));