microsoft / microsoft/TypeScript
Guidance on reducing heap usage of large typings?
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
I maintain google/schema-dts which generates typings for schema.org JSON-LD. The generated typings are ~10k loc and involves a lot of type unions (e.g. Thing can be Organization or CreativeWork or Person or ...), and these can get pretty nested.
Compiling these works for me and the vast majority of users. But I get constant reports of JavaScript heap OOM errors from users consuming the typings. See google/schema-dts#34. I haven't been able to repro this at all, but I'm still hoping for some guidance on getting a better memory footprint for the type checker.
FYI, the .d.ts file looks something like this: https://unpkg.com/schema-dts@0.5.1/schema.d.ts
Questions (I'd take answers to any of these):
- Are there better strategies for writing these in a more memory friendly way? e.g. naming intermediate types, or declaring all properties in one huge object and defining respective types in terms of
Pick<>? - Are there any profiling tools that anyone would recommend using to track this down?
- any other advice is appreciated.
Unfortunately splitting the types up isn't an option (at least not obviously) because the types are deeply self referential.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando schema-dts#34 e l'esempio di schema.d.ts generato collegato nel report. L'issue non indica alcun punto di ingresso del codice sorgente TypeScript, alcun progetto riproducibile né alcun test fallito; un risultato utile sarebbe una riproduzione confermata e indicazioni concrete su pattern di dichiarazione efficienti in termini di memoria o sul profiling.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers, performance
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100