microsoft / microsoft/TypeScript

Guidance on reducing heap usage of large typings?

オープン
#37,214 コメント 12 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Docs
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

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):

  1. 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<>?
  2. Are there any profiling tools that anyone would recommend using to track this down?
  3. 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず schema-dts#34 と、レポートにリンクされている生成済み schema.d.ts の例を確認してください。この issue には TypeScript のソースエントリポイント、再現可能なプロジェクト、または失敗するテストが記載されていません。確認済みの再現手順と、メモリ効率のよい宣言パターンまたはプロファイリングに関する具体的な指針が得られれば、有用な成果となります。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers, performance
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。