Skip to content

match tsc's behaviour when printing diagnostics context #9

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

k-yle
Copy link
Contributor

@k-yle k-yle commented Apr 3, 2025

When printing diagnostics, the typescript CLI first checks process.env.NO_COLOR and !process.stdout.isTTY to decide whether it should print with colours & context, or not.

Currently, this library always uses ts.formatDiagnosticsWithColorAndContext; so this PR updates the behaviour to match the tsc CLI.

Test plan:

  • run the CLI normally → it uses the pretty formatting
  • run the CLI with NO_COLOR=1 … → it uses the machine-readable formatting
  • run the CLI with … | cat → it uses the machine-readable formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant