microsoft / microsoft/TypeScript

Performance of getSemanticDiagnostics in compiler API

Aperta
#5,192 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: API Help Wanted Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

The setup is somewhat similar to the one in the compiler API example (https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services)

The problem, as in the example, is that errors are reported only for files that were directly changed. It doesn't cover the case in which the changed file was a dependency of another file, and even though the file depending on it was not changed, it will still have errors, which won't be reported.

To be more specific, the setup I am talking about is ts-loader + webpack.

What happens is that getSemanticDiagnostics(file) has to be called for every file in the project, which ends up increasing the incremental build times considerably. Even program.getSemanticDiagnostics() iterates through all of the source files as it is seen in the typescript source code.

I can only see this problem fixed from the compiler API. It could expose a method which finds all files dependent on a given file. Because in an incremental build only a single file changed, this should be faster than calling getSemanticDiagnostics() for each and every project file.

The alternative would be some sort of caching on getSemanticDiagnostics() itself, but the compiler would probably have to do internally the same work as above to invalidate the cache on file change. This seems to be equivalent to a getSemanticDiagnosticsForFileAndDependents(file)-like function.

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 leggendo l’implementazione della TypeScript compiler API di getSemanticDiagnostics(file) e program.getSemanticDiagnostics(), incluso il codice sorgente a cui si fa riferimento nell’issue. Determina in che modo le build incrementali identificano i file che dipendono da un file modificato, quindi valuta un approccio basato su un’API o sul caching che eviti di controllare ogni file del progetto continuando comunque a segnalare tutte le diagnosi interessate.

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

Valutazione

Stack tecnologico
typescript
Ambito
api, compilers, performance
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.