microsoft / microsoft/TypeScript
Guidance on reducing heap usage of large typings?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
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 der Durchsicht von schema-dts#34 und des im Bericht verlinkten generierten schema.d.ts-Beispiels. Das Issue nennt keinen TypeScript-Quell-Einstiegspunkt, kein reproduzierbares Projekt und keinen fehlschlagenden Test; ein nützliches Ergebnis wäre eine bestätigte Reproduktion und konkrete Hinweise zu speicherschonenden Deklarationsmustern oder zum Profiling.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers, performance
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100