Handle FORCE_COLOR values like Node - #63941
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #63888