Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsc --watch should clear screen on new compilation #17756

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/compiler/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace ts {
/*@internal*/ debugMode?: boolean;
setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
clearTimeout?(timeoutId: any): void;
clearScreen?(): void;
}

export interface FileWatcher {
Expand Down Expand Up @@ -342,6 +343,9 @@ namespace ts {

const noOpFileWatcher: FileWatcher = { close: noop };
const nodeSystem: System = {
clearScreen: () => {
process.stdout.write("\x1Bc");
},
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames,
Expand Down
7 changes: 7 additions & 0 deletions src/compiler/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ namespace ts {
}

if (isWatchSet(commandLine.options)) {
if (sys.clearScreen) {
sys.clearScreen();
}

if (!sys.watchFile) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* host */ undefined);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
Expand Down Expand Up @@ -402,6 +406,9 @@ namespace ts {
}

function recompile() {
if (sys.clearScreen()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know why it was not working.. this should be if (sys.clearScreen) instead.

sys.clearScreen();
}
timerHandleForRecompilation = undefined;
reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation));
performCompilation();
Expand Down