Skip to content

Commit 24c47f1

Browse files
committed
Merge pull request #7371 from Microsoft/checkForWatchFile
Fix #7362: check for --watchFile in tsconfig.json as well as on the c…
2 parents 0f6dbd0 + 30a6a33 commit 24c47f1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/compiler/tsc.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ namespace ts {
386386
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
387387
return;
388388
}
389+
if (isWatchSet(configParseResult.options) && !sys.watchFile) {
390+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined);
391+
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
392+
}
389393
return configParseResult;
390394
}
391395

@@ -445,7 +449,7 @@ namespace ts {
445449
}
446450
// Use default host function
447451
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
448-
if (sourceFile && isWatchSet(compilerOptions)) {
452+
if (sourceFile && isWatchSet(compilerOptions) && sys.watchFile) {
449453
// Attach a file watcher
450454
const filePath = toPath(sourceFile.fileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
451455
sourceFile.fileWatcher = sys.watchFile(filePath, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));

0 commit comments

Comments
 (0)