Merge pull request #25416 from Microsoft/tscDiagnostics

Fix typo to fix logging when built with --watch --diagnostics
This commit is contained in:
Sheetal Nandi 2018-07-03 14:00:02 -07:00 committed by GitHub
commit dcb74a6027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 16 deletions

View file

@ -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<string>(watchLogLevel, writeLog);

View file

@ -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", () => {