microsoft / microsoft/TypeScript

Unexpected behavior when static methods are used in an array

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

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

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

説明

TypeScript Version: 4.2.0-dev.20201211 (also tested with 4.2.0)

Search Terms: static method(s)

Code

class S {
  static f(a: number|string): void {}
}

function g(a: number): void {}

// Uncomment to see a different behavior of the `output` const type.
// type G = typeof g;

const y = [S.f, g];
const output: ((ctrl: number|string) => void)[] = y;

Expected behavior:
Consistent type checking result (an error) for the output const with and without type G = typeof g.

Actual behavior:
If the type G = typeof g is present, the error is thrown (as expected), otherwise there is no error thrown.

Playground Link:
Playground link to reproduce the error.

// cc @alxhub @rkirov

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

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

はじめの一歩

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

調査の方向性

リンクされた TypeScript Playground と、S.f、g、出力の代入を使った縮小例から始めてください。G エイリアスの有無で型チェックを比較し、その後、両方のバージョンが一貫して期待されるエラーを報告することを確認して修正を検証してください。

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

評価

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

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

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