microsoft / microsoft/TypeScript
Add support for FORCE_COLOR environment variable to tsc
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Nell'issue non viene indicato alcun file del repository né alcun test. Inizia individuando la gestione dell'output a colori di tsc, quindi confronta i valori FORCE_COLOR richiesti con il comportamento di supports-color collegato; il lavoro è completato quando tsc rispetta gli override documentati mantenendo al contempo il normale comportamento dell'output.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100