microsoft / microsoft/TypeScript
Add support for FORCE_COLOR environment variable to tsc
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
En el issue no se menciona ningún archivo del repositorio ni ninguna prueba. Empieza por localizar el procesamiento de la salida en color de tsc y, a continuación, compara los valores de FORCE_COLOR solicitados con el comportamiento de supports-color enlazado; el trabajo está terminado cuando tsc respeta las anulaciones documentadas y conserva el comportamiento normal de la salida.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- cli
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100