diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index 7593f4f5434..decbb835a8c 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -187,8 +187,22 @@ namespace ts {
const typeReferenceExtensions = [".d.ts"];
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
- return options.typeRoots ||
- map(defaultTypeRoots, d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d));
+ if (options.typeRoots) {
+ return options.typeRoots;
+ }
+
+ let currentDirectory: string;
+ if (options.configFilePath) {
+ currentDirectory = getDirectoryPath(options.configFilePath);
+ }
+ else if (host.getCurrentDirectory) {
+ currentDirectory = host.getCurrentDirectory();
+ }
+
+ if (!currentDirectory) {
+ return undefined;
+ }
+ return map(defaultTypeRoots, d => combinePaths(currentDirectory, d));
}
/**
diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts
index e48d6192017..e4b989b0ca7 100644
--- a/src/server/editorServices.ts
+++ b/src/server/editorServices.ts
@@ -113,6 +113,7 @@ namespace ts.server {
this.moduleResolutionHost = {
fileExists: fileName => this.fileExists(fileName),
readFile: fileName => this.host.readFile(fileName),
+ getCurrentDirectory: () => this.host.getCurrentDirectory(),
directoryExists: directoryName => this.host.directoryExists(directoryName)
};
}
diff --git a/tests/cases/fourslash/server/typeReferenceOnServer.ts b/tests/cases/fourslash/server/typeReferenceOnServer.ts
new file mode 100644
index 00000000000..574ea6f60c4
--- /dev/null
+++ b/tests/cases/fourslash/server/typeReferenceOnServer.ts
@@ -0,0 +1,9 @@
+///
+
+///////
+////var x: number;
+////x./*1*/
+
+goTo.marker("1");
+verify.not.completionListIsEmpty();
+