microsoft / microsoft/TypeScript
Automatic `skipDefaultLibCheck` (and potentially `skipLibCheck`)
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
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 ifAhas 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?
- If it's the only checking merged entities, does
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.tswouldn't see erroneous changes in a compiler (so we'd likely need aforceDefaultLibCheck).
Pros
- Running with
skipDefaultLibCheckremoves 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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
type-checker のシンボルマージの動作と、ユーザーファイルより前に lib.d.ts ファイルが読み込まれる仕組みを確認する。既存の skipDefaultLibCheck と skipLibCheck の動作を追跡する。完了の条件は、マージされたシンボルに関する未解決の疑問と forceDefaultLibCheck エスケープハッチを含む、安全な自動チェックルールを定義して検証すること。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 20/100