microsoft / microsoft/TypeScript

Creating too many types for DOM & D3

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

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

Domain: Performance
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Commit 06fe1ed53721862b56c61ebb89b1daee2bc10710 introduced a regression in the number of types created when compiling a snippet of @types\d3. Specifically, it appears to be elaborating types for an error message that ends up getting dropped.

Repro:

{
  "compileOnSave": false,
  "compilerOptions": {
    "alwaysStrict": true,
    "noImplicitAny": true,
    "noEmit": true,
    "lib": [ "es5", "dom" ],
    "noResolve": true,
    "types": [],
    "skipLibCheck": true
  },
  "files": [
    "test.ts",
}

test.ts

declare function select<GElement extends BaseType, OldDatum>(selector: string): Selection2<GElement, OldDatum, HTMLElement, any>;

type BaseType = Element | Document | Window | null | number;

type ValueFn<T extends BaseType, Datum, Result> = (this: T, datum: Datum, index: number, groups: T[] | ArrayLike<T>) => Result;

interface Selection2<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> {
    select<DescElement extends BaseType>(selector: ValueFn<GElement, Datum, DescElement>): Selection2<DescElement, Datum, PElement, PDatum>;
}

For an apples-to-apples comparison, use nolib and specify the 3.1 lib.es5.d.ts and lib.dom.d.ts for both compilations.

In round numbers, there are ~150 types without the change and ~2500 types with the change.

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

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

はじめの一歩

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

調査の方向性

提供された compilerOptions と test.ts スニペットで問題を再現し、3.1 の lib.es5.d.ts ファイルと lib.dom.d.ts ファイルを使用して、約 150 と 2500 の型数を比較します。コミット 06fe1ed53721862b56c61ebb89b1daee2bc10710 と、コンパイラのエラーメッセージの展開処理の経路を調査します。完了条件は、再現コードをコンパイルしても破棄されたエラーメッセージの型が展開されなくなることです。

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

評価

技術スタック
d3, typescript
領域
compilers, performance
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
32/100

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

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