Typescript: Please revert the breaking change in tsc -w that clears output

Created on 15 May 2018  Â·  5Comments  Â·  Source: microsoft/TypeScript

Search Terms

tsc -w
clear

17756

Suggestion

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)

Summary:

tsc -w should not clear screen on re-compile. Add another option like --clearOutputWatch or similar.

Use Cases

Any scripts using tsc

Examples

n.a.

Checklist

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)

Awaiting More Feedback Suggestion

Most helpful comment

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.

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MartynasZilinskas picture MartynasZilinskas  Â·  3Comments

Antony-Jones picture Antony-Jones  Â·  3Comments

fwanicka picture fwanicka  Â·  3Comments

bgrieder picture bgrieder  Â·  3Comments

siddjain picture siddjain  Â·  3Comments