diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 19f851414a2..11dd550340e 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -53,6 +53,14 @@ interface Array { length: number; [n: number]: T; }` return host; } + export function createVirtualServerHost(params: VirtualServerHostCreationParameters): VirtualServerHost { + const host = new VirtualServerHost(params); + host.init(); + // Just like sys, patch the host to use writeFile + patchWriteFileEnsuringDirectory(host); + return host; + } + class Callbacks { private map: TimeOutCallback[] = []; private nextId = 1; diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index a3b36f64d75..1e6e2e0dc7f 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -58,11 +58,18 @@ namespace ts.server { console.warn = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err); console.error = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err); - const fshost = vfs ? VirtualFS.createVirtualServerHost([], { - useCaseSensitiveFileNames: sys.useCaseSensitiveFileNames, - executingFilePath: "", // TODO: "" is the default..maybe this should be vfs, vfs:// or . - newLine: sys.newLine, - }) : sys as ServerHost; + let fshost + if (vfs) { + fshost = new VirtualFS.VirtualServerHost({ + useCaseSensitiveFileNames: sys.useCaseSensitiveFileNames, + executingFilePath: "", // TODO: "" is the default..maybe this should be vfs, vfs:// or . + newLine: sys.newLine, + }) + fshost.init() + } + else { + fshost = sys as ServerHost; + } startServer( { globalPlugins: findArgumentStringArray("--globalPlugins"), diff --git a/src/vfs/virtualFileSystemWithWatch.ts b/src/vfs/virtualFileSystemWithWatch.ts index 9de22ae7ef8..6ebd17073bc 100644 --- a/src/vfs/virtualFileSystemWithWatch.ts +++ b/src/vfs/virtualFileSystemWithWatch.ts @@ -8,14 +8,6 @@ namespace ts.VirtualFS { windowsStyleRoot?: string; } - export function createVirtualServerHost(params: VirtualServerHostCreationParameters): VirtualServerHost { - const host = new VirtualServerHost(params); - host.init(); - // Just like sys, patch the host to use writeFile - patchWriteFileEnsuringDirectory(host); - return host; - } - export interface File { path: string; content: string;