microsoft / microsoft/TypeScript

Add support for FORCE_COLOR environment variable to tsc

Ouverte
#44,233 0 commentaires 7 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

In Discussion Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.4k
Merge moyen
1 j 19 h
PR mergées (30 j)
117

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Aucun fichier du dépôt ni aucun test n’est mentionné dans l’issue. Commencez par localiser la gestion de la sortie en couleur de tsc, puis comparez les valeurs FORCE_COLOR demandées avec le comportement de supports-color lié ; le travail est terminé lorsque tsc respecte les remplacements documentés tout en préservant le comportement normal de la sortie.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
cli
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.