Add getCurrentDirectory to ServerHost
This commit is contained in:
parent
6be7d9caa6
commit
6ff91b84ab
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
};
|
||||
}
|
||||
|
|
9
tests/cases/fourslash/server/typeReferenceOnServer.ts
Normal file
9
tests/cases/fourslash/server/typeReferenceOnServer.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/// <reference path='../fourslash.ts' />
|
||||
|
||||
/////// <reference types="foo" />
|
||||
////var x: number;
|
||||
////x./*1*/
|
||||
|
||||
goTo.marker("1");
|
||||
verify.not.completionListIsEmpty();
|
||||
|
Loading…
Reference in a new issue