Skip to content

Commit dcb74a6

Browse files
authored
Merge pull request microsoft#25416 from Microsoft/tscDiagnostics
Fix typo to fix logging when built with --watch --diagnostics
2 parents e1a7f84 + 4175773 commit dcb74a6

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/compiler/watch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ namespace ts {
490490

491491
const trace = host.trace && ((s: string) => { host.trace!(s + newLine); });
492492
const watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? WatchLogLevel.Verbose :
493-
compilerOptions.diagnostis ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None;
493+
compilerOptions.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None;
494494
const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? trace! : noop; // TODO: GH#18217
495495
const { watchFile, watchFilePath, watchDirectory } = getWatchFactory<string>(watchLogLevel, writeLog);
496496

src/testRunner/unittests/tscWatchMode.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,38 +2313,45 @@ declare module "fs" {
23132313
});
23142314

23152315
describe("tsc-watch console clearing", () => {
2316+
const currentDirectoryLog = "Current directory: / CaseSensitiveFileNames: false\n";
2317+
const fileWatcherAddedLog = [
2318+
"FileWatcher:: Added:: WatchInfo: f.ts 250 Source file\n",
2319+
"FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 Source file\n"
2320+
];
2321+
2322+
function getProgramSynchronizingLog(options: CompilerOptions) {
2323+
return [
2324+
"Synchronizing program\n",
2325+
"CreatingProgramWith::\n",
2326+
" roots: [\"f.ts\"]\n",
2327+
` options: ${JSON.stringify(options)}\n`
2328+
];
2329+
}
2330+
23162331
function checkConsoleClearing(options: CompilerOptions = {}) {
23172332
const file = {
23182333
path: "f.ts",
23192334
content: ""
23202335
};
23212336
const files = [file, libFile];
23222337
const disableConsoleClear = options.diagnostics || options.extendedDiagnostics || options.preserveWatchOutput;
2338+
const hasLog = options.extendedDiagnostics || options.diagnostics;
23232339
const host = createWatchedSystem(files);
23242340
createWatchOfFilesAndCompilerOptions([file.path], host, options);
2325-
checkOutputErrorsInitial(host, emptyArray, disableConsoleClear, options.extendedDiagnostics ? [
2326-
"Current directory: / CaseSensitiveFileNames: false\n",
2327-
"Synchronizing program\n",
2328-
"CreatingProgramWith::\n",
2329-
" roots: [\"f.ts\"]\n",
2330-
" options: {\"extendedDiagnostics\":true}\n",
2331-
"FileWatcher:: Added:: WatchInfo: f.ts 250 Source file\n",
2332-
"FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 Source file\n"
2341+
checkOutputErrorsInitial(host, emptyArray, disableConsoleClear, hasLog ? [
2342+
currentDirectoryLog,
2343+
...getProgramSynchronizingLog(options),
2344+
...(options.extendedDiagnostics ? fileWatcherAddedLog : emptyArray)
23332345
] : undefined);
23342346

23352347
file.content = "//";
23362348
host.reloadFS(files);
23372349
host.runQueuedTimeoutCallbacks();
2338-
checkOutputErrorsIncremental(host, emptyArray, disableConsoleClear, options.extendedDiagnostics ? [
2350+
checkOutputErrorsIncremental(host, emptyArray, disableConsoleClear, hasLog ? [
23392351
"FileWatcher:: Triggered with /f.ts1:: WatchInfo: f.ts 250 Source file\n",
23402352
"Scheduling update\n",
23412353
"Elapsed:: 0ms FileWatcher:: Triggered with /f.ts1:: WatchInfo: f.ts 250 Source file\n"
2342-
] : undefined, options.extendedDiagnostics ? [
2343-
"Synchronizing program\n",
2344-
"CreatingProgramWith::\n",
2345-
" roots: [\"f.ts\"]\n",
2346-
" options: {\"extendedDiagnostics\":true}\n"
2347-
] : undefined);
2354+
] : undefined, hasLog ? getProgramSynchronizingLog(options) : undefined);
23482355
}
23492356

23502357
it("without --diagnostics or --extendedDiagnostics", () => {

0 commit comments

Comments
 (0)