Skip to content

Commit ffe50a3

Browse files
committed
No Watching
1 parent 5726838 commit ffe50a3

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/compiler/watch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ namespace ts {
233233
}
234234

235235
export const noopFileWatcher: FileWatcher = { close: noop };
236+
export const returnNoopFileWatcher = () => noopFileWatcher;
236237

237238
export function createWatchHost(system = sys, reportWatchStatus?: WatchStatusReporter): WatchHost {
238239
const onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
239240
return {
240241
onWatchStatusChange,
241-
watchFile: maybeBind(system, system.watchFile) || (() => noopFileWatcher),
242-
watchDirectory: maybeBind(system, system.watchDirectory) || (() => noopFileWatcher),
242+
watchFile: maybeBind(system, system.watchFile) || returnNoopFileWatcher,
243+
watchDirectory: maybeBind(system, system.watchDirectory) || returnNoopFileWatcher,
243244
setTimeout: maybeBind(system, system.setTimeout) || noop,
244245
clearTimeout: maybeBind(system, system.clearTimeout) || noop
245246
};

src/server/editorServices.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,13 @@ namespace ts.server {
724724
const watchLogLevel = this.logger.hasLevel(LogLevel.verbose) ? WatchLogLevel.Verbose :
725725
this.logger.loggingEnabled() ? WatchLogLevel.TriggerOnly : WatchLogLevel.None;
726726
const log: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? (s => this.logger.info(s)) : noop;
727-
this.watchFactory = getWatchFactory(watchLogLevel, log, getDetailWatchInfo);
727+
this.watchFactory = this.syntaxOnly ?
728+
{
729+
watchFile: returnNoopFileWatcher,
730+
watchFilePath: returnNoopFileWatcher,
731+
watchDirectory: returnNoopFileWatcher,
732+
} :
733+
getWatchFactory(watchLogLevel, log, getDetailWatchInfo);
728734
}
729735

730736
toPath(fileName: string) {

src/server/project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ namespace ts.server {
947947

948948
// update builder only if language service is enabled
949949
// otherwise tell it to drop its internal state
950-
if (this.languageServiceEnabled) {
950+
if (this.languageServiceEnabled && !this.projectService.syntaxOnly) {
951951
// 1. no changes in structure, no changes in unresolved imports - do nothing
952952
// 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files
953953
// (can reuse cached imports for files that were not changed)
@@ -1070,7 +1070,7 @@ namespace ts.server {
10701070
}
10711071

10721072
// Watch the type locations that would be added to program as part of automatic type resolutions
1073-
if (this.languageServiceEnabled) {
1073+
if (this.languageServiceEnabled && !this.projectService.syntaxOnly) {
10741074
this.resolutionCache.updateTypeRootsWatch();
10751075
}
10761076
}

0 commit comments

Comments
 (0)