microsoft / microsoft/TypeScript

Reduce amount of code necessary to quickly format the diagnostics to a string

Aperta
#35,486 0 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dai punti di ingresso dell’API del compilatore TypeScript formatDiagnostics, formatDiagnostic e formatDiagnosticsWithColorAndContext, quindi traccia come FormatDiagnosticsHost sia attualmente richiesto. Confronta gli approcci proposti con host opzionale e host predefinito, preservando le chiamate esistenti. Il lavoro sarà completato quando sarà possibile formattare rapidamente i diagnostic senza passare un host e il comportamento esistente resterà invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
api, compilers
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.