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.
I do not think we want to keep adding new flags.
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.
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'
@clarkdave You are my hero!!!
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?
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.
@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.
@TimonVS Works fine for me. Just install gnu-sed
via brew
.
@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.
@TimonVS Oh, yeah. No doubt! The gnu-sed
is hopefully a temporary workaround that we can get rid of soon.
@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
).
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.
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:
@mhegazy Multiple devs creating _hacky workarounds_, which should be a simple compiler option. Don't you think it should just be added?
We need an option to prevent clearing. Who's idea was it to clear old logs?
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) https://github.com/Microsoft/vscode/issues/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.
--preserveWatchOutput
should address the issue. it should be available in typescript@next
as of tonight.
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 :(
2.8 RC should be out in 2 weeks. and 2.8.1 should be out in 4 weeks.
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
Most helpful comment
We need an option to prevent clearing. Who's idea was it to clear old logs?