From 4175773637c25182605b1ce06af433ef7988f159 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 3 Jul 2018 12:48:28 -0700 Subject: [PATCH] Fix typo to fix logging when built with --watch --diagnostics --- src/compiler/watch.ts | 2 +- src/testRunner/unittests/tscWatchMode.ts | 37 ++++++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index e869dfc966..5082bef2e8 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -490,7 +490,7 @@ namespace ts { const trace = host.trace && ((s: string) => { host.trace!(s + newLine); }); const watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? WatchLogLevel.Verbose : - compilerOptions.diagnostis ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; + compilerOptions.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? trace! : noop; // TODO: GH#18217 const { watchFile, watchFilePath, watchDirectory } = getWatchFactory(watchLogLevel, writeLog); diff --git a/src/testRunner/unittests/tscWatchMode.ts b/src/testRunner/unittests/tscWatchMode.ts index ed03c6ad48..13361d1300 100644 --- a/src/testRunner/unittests/tscWatchMode.ts +++ b/src/testRunner/unittests/tscWatchMode.ts @@ -2313,6 +2313,21 @@ declare module "fs" { }); describe("tsc-watch console clearing", () => { + const currentDirectoryLog = "Current directory: / CaseSensitiveFileNames: false\n"; + const fileWatcherAddedLog = [ + "FileWatcher:: Added:: WatchInfo: f.ts 250 Source file\n", + "FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 Source file\n" + ]; + + function getProgramSynchronizingLog(options: CompilerOptions) { + return [ + "Synchronizing program\n", + "CreatingProgramWith::\n", + " roots: [\"f.ts\"]\n", + ` options: ${JSON.stringify(options)}\n` + ]; + } + function checkConsoleClearing(options: CompilerOptions = {}) { const file = { path: "f.ts", @@ -2320,31 +2335,23 @@ declare module "fs" { }; const files = [file, libFile]; const disableConsoleClear = options.diagnostics || options.extendedDiagnostics || options.preserveWatchOutput; + const hasLog = options.extendedDiagnostics || options.diagnostics; const host = createWatchedSystem(files); createWatchOfFilesAndCompilerOptions([file.path], host, options); - checkOutputErrorsInitial(host, emptyArray, disableConsoleClear, options.extendedDiagnostics ? [ - "Current directory: / CaseSensitiveFileNames: false\n", - "Synchronizing program\n", - "CreatingProgramWith::\n", - " roots: [\"f.ts\"]\n", - " options: {\"extendedDiagnostics\":true}\n", - "FileWatcher:: Added:: WatchInfo: f.ts 250 Source file\n", - "FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 Source file\n" + checkOutputErrorsInitial(host, emptyArray, disableConsoleClear, hasLog ? [ + currentDirectoryLog, + ...getProgramSynchronizingLog(options), + ...(options.extendedDiagnostics ? fileWatcherAddedLog : emptyArray) ] : undefined); file.content = "//"; host.reloadFS(files); host.runQueuedTimeoutCallbacks(); - checkOutputErrorsIncremental(host, emptyArray, disableConsoleClear, options.extendedDiagnostics ? [ + checkOutputErrorsIncremental(host, emptyArray, disableConsoleClear, hasLog ? [ "FileWatcher:: Triggered with /f.ts1:: WatchInfo: f.ts 250 Source file\n", "Scheduling update\n", "Elapsed:: 0ms FileWatcher:: Triggered with /f.ts1:: WatchInfo: f.ts 250 Source file\n" - ] : undefined, options.extendedDiagnostics ? [ - "Synchronizing program\n", - "CreatingProgramWith::\n", - " roots: [\"f.ts\"]\n", - " options: {\"extendedDiagnostics\":true}\n" - ] : undefined); + ] : undefined, hasLog ? getProgramSynchronizingLog(options) : undefined); } it("without --diagnostics or --extendedDiagnostics", () => {