tsc -w
clear
Revert the default clearing of console on re-compile using tsc -w
The current (new) imlementation is really annoying. All scripts and packages by others using tsc -w now clears the console and people have to modify packages and scripts. All the people who likes it to clear the screen (as a new) feature should use an option instead of breaking existing functionality.
(@k0pernikus)
tsc -w should not clear screen on re-compile. Add another option like --clearOutputWatch or similar.
Any scripts using tsc
n.a.
My suggestion meets these guidelines:
[x] This wouldn't be a breaking change in existing TypeScript / JavaScript code (it would "UNBREAK" TypeScript after you broke it)
[x] This wouldn't change the runtime behavior of existing JavaScript code
[x] This could be implemented without emitting different JS based on the types of the expressions
[x] This isn't a runtime feature (e.g. new expression-level syntax)
This is really stretching the definition of "breaking change".
preserveWatchOutput exists and it makes a lot more sense for tool authors to write that once than for people running from the commandline to type it every time.
If people running tsc themselves want this to be the default, we can gather feedback on that, but we're not going to flip-flop because script authors took a dependency on how a long-running process manages the console.
If you want a relatively stable API for program watching, use that: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#writing-an-incremental-program-watcher
Please don't rely on our interactive mode's behavior.
The use case, where I experience the problem is when you use docker-compose to spin up several servers. All the outputs goes to the same console (color coded). As soon as tsc runs it clears the console - i.e. output from all servers. As you say, the authors of the tools / packages could re-write their scripts. I just don’t understand why anybody wants to clear the screen at recompile - they also lose any info about what happened before. Even the vscode terminal programmer had an issue with this (see #17756 ). @DanielRosenwasser - I don’t want an API - just want to run the compiler in watch mode without it interfering with other console outputs. Could it be a tsconfig.js setting, that overrides command-line options, which might make everybody happy?
Adding "preserveWatchOutput": true in the compilerOptions in your tsconfig aughta work?
Yes! It does - didn't know it existed. Then that would solve most issues I think. Thanks @weswigham
Most helpful comment
This is really stretching the definition of "breaking change".
preserveWatchOutputexists and it makes a lot more sense for tool authors to write that once than for people running from the commandline to type it every time.If people running
tscthemselves want this to be the default, we can gather feedback on that, but we're not going to flip-flop because script authors took a dependency on how a long-running process manages the console.