microsoft / microsoft/TypeScript

Add support for FORCE_COLOR environment variable to tsc

Offen
#44,233 0 Kommentare 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

Suggestion

🔍 Search Terms

FORCE_COLOR

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

https://github.com/chalk/supports-color/blob/main/index.js

Among the npm/js ecosystem it is common to support overriding color output through an environment variable named FORCE_COLOR. The most commonly used implementation being the 'supports-color' library maintained by the 'chalk' team, linked above. The basic behavior is...

If FORCE_COLOR is "0" or "false" then force plain, uncolored output
If FORCE_COLOR is "1" or "true" then force 16 color ANSI output
If FORCE_COLOR is "2" then force 256 color ANSI output
If FORCE_COLOR is "3" then force full 24-bit RGB output

This ends up being particularly useful for writing tools that act as wrappers around tsc, which might spawn a tsc process and then display its output.

I think the tsc only ever uses 16 color output, which would simplify implementation a little bit.

📃 Motivating Example

The ability to run tsc in a task harness, while still getting colored output, without needing to do any weird argument/configuration injecting.

💻 Use Cases

The particular use case that I'm working on is a CLI tool that can invoke other CLI tools in parallel, such as ESLint, TSC, Prettier, Jest, TypeDoc, etc. The output of each process is piped into a set of buffers until the process exits, and then the buffer is piped out to stdout/stderr as appropriate. You get the speed benefits of running all the tooling in parallel, without needing to have 5+ terminals open to run them all manually, and without the output of each tool getting mixed with the output of others and becoming mangled and hard to read.

[jest]
--- Full color, continuous Jest output ---
[tsc]
--- Full color, continuous tsc output ---

etc.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

In der Issue wird keine Repository-Datei und kein Test genannt. Beginne damit, die Verarbeitung der Farbausgabe von tsc zu lokalisieren, und vergleiche dann die angeforderten FORCE_COLOR-Werte mit dem verlinkten supports-color-Verhalten; abgeschlossen ist die Aufgabe, wenn tsc die dokumentierten Überschreibungen berücksichtigt und gleichzeitig das normale Ausgabeverhalten beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
cli
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.