| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Do we... Have a way we can test this? Oh! Maybe We could write a unit test that shells out to the built local tsc and baselines the output!
Locals pretty straightforward; you got any details on what terms/apps this causes pretty by default in now?
Sorry, something went wrong.
|
I know the last time I did this (i.e. when I originally wrote --pretty), there were issues with either Cygwin's bash terminal or MinGW. I forgot which, but I'll have to peek at that again. Tests are Monday-Daniel-and-Wesley's problem. 😄 |
Sorry, something went wrong.
| function shouldBePretty(options: CompilerOptions) { | ||
| if ((typeof options.pretty === "undefined" && typeof options.diagnosticStyle === "undefined") || options.diagnosticStyle === DiagnosticStyle.Auto) { | ||
| return !!sys.writeOutputIsTty && sys.writeOutputIsTty(); | ||
| } |
There was a problem hiding this comment.
spacing
Sorry, something went wrong.
| pretty: DiagnosticStyle.Pretty, | ||
| simple: DiagnosticStyle.Simple, | ||
| }), | ||
| }, |
There was a problem hiding this comment.
spacing
Sorry, something went wrong.
| } | ||
| } | ||
|
|
||
| function shouldBePretty(options: CompilerOptions) { |
There was a problem hiding this comment.
So now there are two CLI flags that can tell tsc it's pretty. What if the user provides tsc --pretty false --diagnosticStyle pretty or tsc --pretty true --diagnosticStyle simple? Should there be a warning for providing both?
Sorry, something went wrong.
| category: Diagnostics.Command_line_Options, | ||
| description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental | ||
| }, | ||
| { |
There was a problem hiding this comment.
I would rather we do not add a new flag if we can. i think auto is just pretty === undefined.
if we really need a new value i would make pretty take boolean | "auto"
Sorry, something went wrong.
There was a problem hiding this comment.
boolean | "auto" | "simple" | "styled"? (Where boolean toggles between auto and styled).
Sorry, something went wrong.
| if ((typeof options.pretty === "undefined" && typeof options.diagnosticStyle === "undefined") || options.diagnosticStyle === DiagnosticStyle.Auto) { | ||
| return !!sys.writeOutputIsTty && sys.writeOutputIsTty(); | ||
| } | ||
| return options.diagnosticStyle === DiagnosticStyle.Pretty || options.pretty; |
There was a problem hiding this comment.
!! options.pretty
Sorry, something went wrong.
There was a problem hiding this comment.
Please 1. remove the extra flag, and 2. test on chakra
Sorry, something went wrong.
| newLine: string; | ||
| useCaseSensitiveFileNames: boolean; | ||
| write(s: string): void; | ||
| writeOutputIsTty?(): boolean; |
There was a problem hiding this comment.
Is this a reasonable name Wesley Wigham (@weswigham)?
Sorry, something went wrong.
There was a problem hiding this comment.
TTY, not Tty.
Sorry, something went wrong.
| } | ||
|
|
||
| function shouldBePretty(options: CompilerOptions) { | ||
| if ((typeof options.pretty === "undefined")) { |
There was a problem hiding this comment.
extra parens.
Sorry, something went wrong.
|
Tried it out. tsc.exe (the Chakra host-wrapped tsc) reverts to the old behavior. Like before, --pretty on tsc.exe produces garbled text when explicitly specified, but that's always been the behavior. I'm going to pull this in so we can get it in tonight's nightly release. |
Sorry, something went wrong.
|
Daniel Rosenwasser (@DanielRosenwasser) please update https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Compiler%20Options.md as well. |
Sorry, something went wrong.
|
Hi Daniel Rosenwasser (@DanielRosenwasser),
I guess this is because tsc.exe doesn't set the console mode on Windows to enable processing of Virtual Terminal Sequences (ENABLE_VIRTUAL_TERMINAL_PROCESSING). (I think Node.js parses these sequences itself and then calls the corresponding APIs like SetConsoleTextAttribute, so that it works also with older Windows versions.) Can tsc.exe be updated to set this console mode? Thanks! |
Sorry, something went wrong.
|
Thanks for the pointers, I might look into it Konstantin Preißer (@kpreisser)! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This pull request always makes TypeScript's output --pretty when the compiler can detect whether its "output device" is appropriate for more colorful output.
If TypeScript's output is a psuedo-TTY, then it will enable today's prettified output and emit escape characters to the console; however, when piping to another file or program, it will automatically turned off.
Programs that want to specify the behavior can specifically set --pretty, or the new --diagnosticStyle flag.
This PR also affords us the room to give more variation in out emit modes. For example, with --diagnosticStyle, we could have a more colorful simple/terse mode as requested in #10745.
Fixes #10488.