microsoft / microsoft/TypeScript

types 'new (...args: any) => E' and wrapper types constructor for primitive types have no overlap

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

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

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

説明

TypeScript Version: 3.8.3

Code

class TreeSet<E> {
    constructor(elementType: new(...args: any) => E) {
        if (elementType === Number) { //This condition will always return 'false' since the types 'new (...args: any) => E' and 'NumberConstructor' have no overlap.(2367)
            console.log("hello")
        }
    }
}

new TreeSet(Number)

Actual behavior:
The error is prompted at compile time "This condition will always return 'false' since the types 'new (...args: any) => E' and 'NumberConstructor' have no overlap.(2367)" but compiled code actually runs correctly.

Playground Link:
https://www.typescriptlang.org/play/?ssl=9&ssc=20&pln=1&pc=1#code/MYGwhgzhAEAqBOBTRBlRAXAPAUQHzQG8AoaU6YAewDsJ14BXYdC+ACkREQFtEr1YAngAdEALmhVEAd1YA6eWHgBzCOLBUBASmgBefNm3Eyx6AEsAZtHacefQSN06d0AHL0uAI0TxDJE-8oaCk5ZEAolVgAiAAsOMMjNP38AXyToVNSiSSk4JFQMVjdPb00gA

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

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

はじめの一歩

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

調査の方向性

TypeScript 3.8.3 playground の再現と、issue に示されている TreeSet コンストラクターの比較から始めてください。ジェネリックコンストラクター型と NumberConstructor の比較に対するコンパイラーの診断を追跡し、続いて提供された例に対して動作を検証して、誤検出の診断が表示されなくなっていることを確認してください。

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

評価

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

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

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