microsoft / microsoft/TypeScript

Automatic `skipDefaultLibCheck` (and potentially `skipLibCheck`)

Aperta
#31,417 2 commenti 6 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: lib.d.ts Domain: Performance In Discussion Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

This issue is adapted from a work item discussed at #25658.

Automatic skipDefaultLibCheck

lib.d.ts is a pretty big file, and it's only going to grow. Realistically, most people don't ever declare symbols that conflict with the global scope, so we made the skipDefaultLibCheck (and also the skipLibCheck flag) for faster compilations.

We can suggest this flag to users, but the truth is that it's not discoverable. It's also often misused, so I want to stop recommending it to people. 😄

It'd be interesting to see if we can get the same results of skipDefaultLibCheck based on the code users have written. Any program that doesn't contribute a global augmentation, or a declaration in the global scope, doesn't really need to have lib.d.ts checked over again.

@mhegazy and I have discussed this, and it sounds like we have the necessary information after the type-checker undergoes symbol-merging. If no symbols ever get merged outside of lib files, we can make the assumption that lib files never need to get checked. But this requires knowing that all lib files have already had symbols merged up front before any other files the compiler is given.

Open Questions

  • Is the idea to only type-check symbols which have been merged? Or is it to fall back to the worst-case behavior of checking everything when any symbol has been merged across files?
    • If it's the only checking merged entities, does declare class B extend A {} need to be re-checked if A has ever been subsequently merged? How would we keep track of that information?
    • If it's falling back to the worst-case behavior, does this feature actually help anyone outside of the "Hello world" case?

Cons

  • It feels like there are certain interactions we may be overlooking - we will have to be careful about our assumptions in the compiler with this behavior in place.
  • Users who edit lib.d.ts wouldn't see erroneous changes in a compiler (so we'd likely need a forceDefaultLibCheck).

Pros

  • Running with skipDefaultLibCheck removes anywhere between 400-700ms on my machine from a "Hello world" file, so we could expect the same here under this behavior.
  • Only our team ever needs to run forceDefaultLibCheck, reducing the cost for all other TypeScript users.

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

Leggi il comportamento del type-checker relativo all'unione dei simboli e il modo in cui i file lib.d.ts vengono caricati prima dei file dell'utente. Traccia il comportamento esistente di skipDefaultLibCheck e skipLibCheck. Il lavoro è completato quando viene definita e convalidata una regola sicura per il controllo automatico, incluse le domande aperte sui simboli uniti e un'escape hatch forceDefaultLibCheck.

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

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
20/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.