microsoft / microsoft/TypeScript
Reduce amount of code necessary to quickly format the diagnostics to a string
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den TypeScript-Compiler-API-Einstiegspunkten formatDiagnostics, formatDiagnostic und formatDiagnosticsWithColorAndContext und verfolge anschließend, wie FormatDiagnosticsHost derzeit erforderlich ist. Vergleiche die vorgeschlagenen Ansätze mit optionalem Host und Standard-Host, wobei bestehende Aufrufe beibehalten werden. Als abgeschlossen gilt die Änderung, wenn Diagnosen schnell formatiert werden können, ohne einen Host zu übergeben, und das bestehende Verhalten unverändert bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- api, compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100