TypeScript Reference ยท The tsc Command Line
tsc --pretty
Reference for tsc --pretty: how the compiler formats error messages with colors and code frames, when it turns on automatically, and how to get plain output.
--pretty controls how tsc prints errors. In pretty mode each diagnostic is colorized, shows the file position as a clickable link, and displays the offending source line with a squiggly underline. In plain mode each error is a single line such as main.ts(3,7): error TS2322: ....
The default depends on where the output goes: pretty when standard output is a terminal, plain when it is redirected to a file or a pipe. You override that with --pretty or --pretty false.
tsc --pretty tsc --pretty false tsc --noEmit --pretty false > errors.txt
Try it
This site shows the plain one-line form, which is the best format for logs. The error text is the same in both modes; only the presentation changes.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Syntax
tsc --pretty [true|false]
{ "compilerOptions": { "pretty": false } }
| Mode | Looks like |
|---|---|
| Pretty | Colored path, a code frame with the line number, and a ~~~ underline under the error. |
| Plain | file(line,col): error TSnnnn: message, one error per line with follow-up lines indented. |
Edge cases: colors are only added when the output can show them; CI systems that attach a pseudo-terminal may show escape codes, so use --pretty false there. Pretty mode ends with a summary such as "Found 2 errors", which plain mode also prints in recent versions.
Usage notes
- Parsing output? Use plain mode. Problem matchers in editors and CI (for example GitHub Actions annotations) are written for the plain format.
- Reading by eye? Pretty mode is easier because the code frame shows context.
- Watch mode clears the screen only in pretty terminals; add
--preserveWatchOutputto keep history. - Environment: some CI variables turn color off automatically, but explicit
--prettyflags always win. - Error codes are stable, so search for
TS2322rather than the message text when asking for help.
Related
- tsc
- tsc --watch
- tsc exit codes
- Tutorial: Tooling