microsoft / microsoft/TypeScript

Missing error on class extending union of incompatible constructor types

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

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

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

説明

TypeScript Version: 4.2.0-dev.20210105, worked in v3.6.3, regressed in v3.7

Search Terms: is not a constructor function type

Expected behavior:

Error: Type 'typeof Base | typeof Base2' is not a constructor function type.
Or super should not be inferred as any.

Actual behavior:

No error and super: any

Related Issues:

Code

class Base {
    prop = 1;
}

class Base2 {
    other = 1;
}

const base = Boolean() ? Base : Base2;

class Derived extends base { // ExpressionWithTypeArguments is inferred as 'any', expected error "Type 'typeof Base | typeof Base2' is not a constructor function type."
    static fn() {
        super.wargarbl.wat; // super is inferred as 'any'
    }
    fn() {
        super.wargarbl.wat; // super is inferred as 'any'
    }
}
Compiler Options
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": 2,
    "target": "ES2017",
    "jsx": "React",
    "module": "ESNext"
  }
}

Playground Link: Provided

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

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

はじめの一歩

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

調査の方向性

TypeScript のコード例と提供されている Playground のリンクから始め、バージョン 3.6.3、3.7、4.2.0-dev の間で報告された動作を比較します。class Derived extends base に対する欠落している診断を再現し、互換性のないコンストラクターの共用体が、superany として推論せずに拒否されることを確認します。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

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

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