microsoft / microsoft/TypeScript
Reduce amount of code necessary to quickly format the diagnostics to a string
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
Description
Search Terms
FormatDiagnosticsHost
Suggestion
Often when someone is working with the TypeScript compiler API their type checker might have diagnostics. It would be useful for people to quickly check them by typing:
ts.formatDiagnostics(ts.getPreEmitDiagnostics(program))
Instead of:
ts.formatDiagnostics(ts.getPreEmitDiagnostics(program), {
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
getCanonicalFileName: f => f,
getNewLine: () => "\n"
})
Possible solution is to make providing FormatDiagnosticsHost optional or add a default FormatDiagnosticsHost that people can use (or both).
Also for ts.formatDiagnostic and ts.formatDiagnosticsWithColorAndContext
Use Cases
Easier for people to quickly check the diagnostics while they're developing with the compiler API.
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, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Related Issues
#29581
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par les points d’entrée de l’API du compilateur TypeScript formatDiagnostics, formatDiagnostic et formatDiagnosticsWithColorAndContext, puis examinez comment FormatDiagnosticsHost est actuellement requis. Comparez les approches proposées avec un host optionnel et un host par défaut, tout en préservant les appels existants. Le travail sera terminé lorsque les diagnostics pourront être rapidement formatés sans passer de host et que le comportement existant restera inchangé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- api, compilers
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100