diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index c9e428468e5..5005fdd2453 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -233,13 +233,14 @@ namespace ts { } export const noopFileWatcher: FileWatcher = { close: noop }; + export const returnNoopFileWatcher = () => noopFileWatcher; export function createWatchHost(system = sys, reportWatchStatus?: WatchStatusReporter): WatchHost { const onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system); return { onWatchStatusChange, - watchFile: maybeBind(system, system.watchFile) || (() => noopFileWatcher), - watchDirectory: maybeBind(system, system.watchDirectory) || (() => noopFileWatcher), + watchFile: maybeBind(system, system.watchFile) || returnNoopFileWatcher, + watchDirectory: maybeBind(system, system.watchDirectory) || returnNoopFileWatcher, setTimeout: maybeBind(system, system.setTimeout) || noop, clearTimeout: maybeBind(system, system.clearTimeout) || noop }; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index f98f0dce2db..acde65db151 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -724,7 +724,13 @@ namespace ts.server { const watchLogLevel = this.logger.hasLevel(LogLevel.verbose) ? WatchLogLevel.Verbose : this.logger.loggingEnabled() ? WatchLogLevel.TriggerOnly : WatchLogLevel.None; const log: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? (s => this.logger.info(s)) : noop; - this.watchFactory = getWatchFactory(watchLogLevel, log, getDetailWatchInfo); + this.watchFactory = this.syntaxOnly ? + { + watchFile: returnNoopFileWatcher, + watchFilePath: returnNoopFileWatcher, + watchDirectory: returnNoopFileWatcher, + } : + getWatchFactory(watchLogLevel, log, getDetailWatchInfo); } toPath(fileName: string) { diff --git a/src/server/project.ts b/src/server/project.ts index 7fcfac7e363..320ff922ce9 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -947,7 +947,7 @@ namespace ts.server { // update builder only if language service is enabled // otherwise tell it to drop its internal state - if (this.languageServiceEnabled) { + if (this.languageServiceEnabled && !this.projectService.syntaxOnly) { // 1. no changes in structure, no changes in unresolved imports - do nothing // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files // (can reuse cached imports for files that were not changed) @@ -1070,7 +1070,7 @@ namespace ts.server { } // Watch the type locations that would be added to program as part of automatic type resolutions - if (this.languageServiceEnabled) { + if (this.languageServiceEnabled && !this.projectService.syntaxOnly) { this.resolutionCache.updateTypeRootsWatch(); } }