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

Allow not clearing the console on recompiles in --pretty --watch mode #21295

Closed
JoshuaKGoldberg opened this issue Jan 19, 2018 · 20 comments
Closed
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@JoshuaKGoldberg
Copy link
Contributor

Repeating @ogvolkov's comment:

Is it possible to still have the old behavior behind the flag?
We are using TypeScript as a part of the gulp file which also contains other tasks (e.g. minify, watch for style changes etc.), and clearing the screen on recompile eventually erases the history of other tasks completely.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 19, 2018

I do not think we want to keep adding new flags.

@DanielRosenwasser DanielRosenwasser added Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds labels Jan 20, 2018
@bdowning
Copy link

bdowning commented Feb 3, 2018

At least on linux with xterm the \x1Bc sequence used by this feature to clear the screen also rings the terminal bell, which gets quite maddening in short order. I can also see how the clearing behavior would be frustrating when used in a non-interactive manner. I would also appreciate a way for this to go away.

@clarkdave
Copy link

clarkdave commented Feb 4, 2018

Another use case: we've been using TypeScript with the new Babel parser, and because there's no type checking it's handy to run tsc --noEmit --watch alongside it, e.g. using foreman, concurrency or similar task runners so that the output stays in one terminal.

Similar scenario when using TS in combination with ts-node, where the type checking is optional (and yields a significant speed increase during development): having the type checking run alongside it in the same terminal is also helpful.

The new behaviour breaks this kind of workflow and pretty much necessitates wrapping/piping tsc or running it in a separate terminal. This workaround has worked OK for me: tsc --noEmit --watch | gsed -u 's/\x1Bc//g'

@roblav96
Copy link

roblav96 commented Feb 9, 2018

@clarkdave You are my hero!!!

@esprehn
Copy link

esprehn commented Feb 10, 2018

We have the same problem. We have a monorepo and lots of tooling that runs 5+ instances of tsc concurrently for various projects. The new behavior breaks all our tools and gsed doesn't come with OS X. Can we get this behavior behind a flag?

@demisx
Copy link

demisx commented Feb 12, 2018

Same problem here. We don't need tsc to have the screen cleared for us. We need consistent linear output as was before. Please make this configurable.

@TimonVS
Copy link

TimonVS commented Feb 16, 2018

@clarkdave the command doesn't work on macOS. MacOS comes with sed but it unfortunately doesn't support the -u (unbuffered) flag, which makes it impossible to fix this issue. I really think that a fix for this issue should be included in TypeScript itself to make TS suitable for monorepos.

@demisx
Copy link

demisx commented Feb 16, 2018

@TimonVS Works fine for me. Just install gnu-sed via brew.

@TimonVS
Copy link

TimonVS commented Feb 16, 2018

@demisx Thanks, I was aware of that :). But that means that I have to force my whole team to install this on their computers. I'm lucky that all my co-workers use macOS (so everyone has the same setup), but I'd still argue that this should be solved by TypeScript itself.

@demisx
Copy link

demisx commented Feb 16, 2018

@TimonVS Oh, yeah. No doubt! The gnu-sed is hopefully a temporary workaround that we can get rid of soon.

@JoshuaKGoldberg
Copy link
Contributor Author

@TimonVS @demisx @clarkdave @roblav96 if it helps, I just published an NPM package tsc-fancy you can use as a drop-in replacement for tsc that includes a --preserveConsoleOutput flag. I've verified it works on Windows and it should on Linux/Mac too - would appreciate verification!

https://www.npmjs.com/package/tsc-fancy

Otherwise, I'm closing this issue since the TS team is against adding the flag in, and there are two workarounds (sed shenanigans and tsc-fancy).

@esprehn
Copy link

esprehn commented Feb 22, 2018

Can we reopen this or revert the watch change? Having to use tsc-fancy to hack around tsc's defaults being hostile to scripts isn't good.

@ogheorghies
Copy link

ogheorghies commented Feb 22, 2018

A portable workaround for scripts is: tsc --watch | awk '{gsub(/\033c/,"") system("")}1'

To customize the actions to be taken when compilation succeeds or fails, such as clear or don't clear screen, say something, record metrics, you can use:

https://www.npmjs.com/package/tsc-do

@roblav96
Copy link

roblav96 commented Feb 23, 2018

@mhegazy Multiple devs creating hacky workarounds, which should be a simple compiler option. Don't you think it should just be added?

@evanjmg
Copy link

evanjmg commented Feb 26, 2018

We need an option to prevent clearing. Who's idea was it to clear old logs?

@Tyriar
Copy link
Member

Tyriar commented Feb 28, 2018

I maintain the terminal in VS Code and I don't think it should clear either. This actually caused an issue in our tasks feature which I had to act on because it's not typical of a build tool and because of how the terminal works under Windows (forces redraws of the entire screen unlike Linux/macOS) microsoft/vscode#44192

There's a reason build tools don't normally touch the rest of the screen outside of rewriting the current line; preserving history, working better with tall terminals, helping users noticing when things change, etc. The change should be be reverted imo.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 1, 2018

--preserveWatchOutput should address the issue. it should be available in typescript@next as of tonight.

@mhegazy mhegazy added Fixed A PR has been merged for this issue and removed Too Complex An issue which adding support for may be too complex for the value it adds labels Mar 1, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Mar 1, 2018
@fbartho
Copy link

fbartho commented Mar 2, 2018

Is there any hope of getting this fixed in 2.7.3? I see it was added to milestone 2.8 which has no due date and is only 35% done :(

@mhegazy
Copy link
Contributor

mhegazy commented Mar 2, 2018

2.8 RC should be out in 2 weeks. and 2.8.1 should be out in 4 weeks.

@hoegge
Copy link

hoegge commented May 2, 2018

This implementation is a mistake. tsc --watch should not clear the console by default. You could add an option that does enable clearing instead. Now people have to modify a lot of code, scripts and tools to add the --preserveWatchOutput option because of this useless breaking change. E.g. read the feedback from @Tyriar

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.