-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Stylize tsc's error messages with color and context #5140
Conversation
Conflicts: src/compiler/sys.ts src/compiler/tsc.ts
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json src/compiler/sys.ts src/compiler/tsc.ts
Conflicts: src/compiler/commandLineParser.ts
Thanks. This should mean that any tools that consume the output from |
@myitcv this was one of the original concerns I heard a lot of from other members of the team; however, I think it would be a good idea to make it a default option in |
One thing I would really appreciate would be some sort of coloring for the "starting incremental recompilation" message, so we can more easily tell which errors are current. |
Awesome that it shows the line numbers! I would also like the message when overflowed to be tabbed to the starting position. For example, the text part I guess you would add colors on the messages too? |
@tinganho I think terminal size detection/wrapping is better left for a separate issue/PR. |
let hasMoreThanFiveLines = (lastLine - firstLine) >= 4; | ||
let gutterWidth = (lastLine + 1 + "").length; | ||
if (hasMoreThanFiveLines) { | ||
gutterWidth = Math.max("...".length, gutterWidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capture the ellipses in a const, and so is its length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also applies to the squiggle down below.
LGTM. a few nits, but other than than that 👍 |
please add a snippet about it in https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript |
a15c0de
to
40f10ab
Compare
Stylize tsc's error messages with color and context
This change seeks to make our output a little easier on the eyes and addresses #3852. I suggest this PR's final changes be reviewed rather than going commit-by-commit.
Firstly, a new flag is introduced:
--diagnosticStyle
. It accepts the optionspretty
andsimple
. It is currently marked as experimental, and we can bikeshed over the names later.If
--diagnosticStyle simple
is used, the user will get the same behavior as they experience today. Note thatsimple
is left as the default.If
--diagnosticStyle pretty
is used as an option, then we check if we are outputting to a terminal-style descriptor. If we are entirely sure, then we stylize the output with color. If not (e.g. output is being piped, forwarded to a file, etc.) we make the output readable so that no special control characters are used in the output.Here's some screenshots/gifs to give you an idea of what this looks like right now.
Monokai
Solarized Light
Terminal Basic
My Stupid Terminal Theme
Cygwin's MinTTY
cmd.exe
GNOME Terminal Defaults in Ubuntu