microsoft / microsoft/TypeScript
T | (() => T)
オープン
まだ誰も着手していません。
Bug
Domain: check: Control Flow
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.9.0 (Nightly)
Search Terms: T | (() => T), T & Function
Code
type Initializer<T> = T | (() => T)
// type Initializer<T> = T extends any ? (T | (() => T)) : never
function correct<T>(arg: Initializer<T>) {
return typeof arg === 'function' ? arg() : arg // error
}
Line 2 provides a workaround for this.
More info on stackoverflow.
Expected behavior: no errors
Actual behavior: This expression is not callable.
Not all constituents of type '(() => T) | (T & Function)' are callable.
Type 'T & Function' has no call signatures.
Playground Link: here.
Related Issues: none
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンクされた TypeScript Playground の再現コードを実行し、Initializer の直接的な定義と distributive conditional workaround を比較します。typeof チェックに関係する型の絞り込みと呼び出し可能性の挙動を追跡します。直接的な定義が報告されたエラーなしでコンパイルでき、期待される型の挙動を維持できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100