Skip to content

Handle FORCE_COLOR values like Node - #63941

Merged
Jake Bailey (jakebailey) merged 3 commits into
microsoft:mainfrom
jakebailey:force-color
Aug 21, 2026
Merged

Handle FORCE_COLOR values like Node#63941
Jake Bailey (jakebailey) merged 3 commits into
microsoft:mainfrom
jakebailey:force-color

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Fixes #63888

Copilot AI balanced review requested due to automatic review settings August 21, 2026 04:52
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 21, 2026
@typescript-automation typescript-automation Bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Aug 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates compiler CLI color detection to match Node.js FORCE_COLOR, NO_COLOR, TERM, and TTY behavior.

Changes:

  • Distinguishes unset environment variables from empty values.
  • Implements Node-compatible color precedence and accepted values.
  • Adds command-line regression coverage for color handling.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tsc/cmd/tsc/sys.go Uses os.LookupEnv to preserve environment-variable presence.
tsc/internal/execute/tsc/compile.go Updates the system environment API.
tsc/internal/execute/tsc/diagnostics.go Implements Node-compatible color selection.
tsc/internal/execute/tsc/emit_test.go Updates test systems for the environment API.
tsc/internal/execute/tsctests/runner.go Adds configurable TTY state to tests.
tsc/internal/execute/tsctests/sys.go Simulates environment presence and TTY output.
tsc/internal/execute/tsctests/tsc_test.go Adds color-environment test scenarios.
tsc/internal/execute/watcher.go Adapts watch debugging to the new API.
tsc/internal/execute/build/orchestrator.go Adapts build-watch debugging to the new API.
tsc/testdata/baselines/reference/tsc/commandLine/FORCE_COLOR-overrides-NO_COLOR.js Verifies FORCE_COLOR precedence.
tsc/testdata/baselines/reference/tsc/commandLine/FORCE_COLOR-overrides-dumb-TERM.js Verifies forced color with a dumb terminal.
tsc/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-TERM-is-dumb.js Verifies dumb-terminal suppression.
tsc/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js Verifies NO_COLOR suppression.
tsc/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set-even-if-FORCE_COLOR-is-set.js Removes the obsolete precedence baseline.
tsc/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-FORCE_COLOR-is-zero.js Verifies FORCE_COLOR=0.
tsc/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-FORCE_COLOR-is-invalid.js Verifies invalid values disable color.
tsc/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-FORCE_COLOR-is-four.js Verifies unsupported color level handling.
tsc/testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-FORCE_COLOR-is-false.js Verifies FORCE_COLOR=false.
tsc/testdata/baselines/reference/tsc/commandLine/adds-color-when-NO_COLOR-is-empty.js Verifies empty NO_COLOR handling.
tsc/testdata/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-two-and-output-is-not-a-TTY.js Verifies forced level-two color.
tsc/testdata/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-true-and-output-is-not-a-TTY.js Verifies forced color using true.
tsc/testdata/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-three-and-output-is-not-a-TTY.js Verifies forced level-three color.
tsc/testdata/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-one-and-output-is-not-a-TTY.js Verifies forced level-one color.
tsc/testdata/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-empty-and-output-is-not-a-TTY.js Verifies empty FORCE_COLOR enables color.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Aug 21, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Aug 21, 2026
Merged via the queue into microsoft:main with commit 31ff973 Aug 21, 2026
22 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the force-color branch August 21, 2026 18:53
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

tsc colours diagnostics when stdout is not a TTY, splitting "error TS2304" and breaking output parsing (regressed in 6.0)

3 participants