microsoft / microsoft/TypeScript
Error inferring types of promise function
オープン
まだ誰も着手していません。
Bug
Domain: check: Type Inference
Has Repro
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
TypeScript Version: nightly (Version 2.5.0-dev.20170816)
Code
(based on DefinitelyTyped/types/bluebird/index.d.ts)
declare function props<K, V>(x: PromiseLike<Map<K, PromiseLike<V> | V>>): Promise<Map<K, V>>;
declare const input: Promise<Map<number, Promise<string>>>;
const out: Promise<Map<number, string>> = props(input);
Expected behavior:
No error.
Actual behavior:
src/a.ts(3,7): error TS2322: Type 'Promise<Map<number, Promise<string>>>' is not assignable to type 'Promise<Map<number, string>>'.
Type 'Map<number, Promise<string>>' is not assignable to type 'Map<number, string>'.
Type 'Promise<string>' is not assignable to type 'string'.
It works if I explicitly specify props<number, string>(input).
The error only reproduces with "lib": ["es6"].
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue にある TypeScript の再現コードから始め、示されている lib: ["es6"] 設定を使用して、props(input) の推論を明示的に型指定した呼び出しと比較してください。明示的な型引数なしで推論された結果を Promise<Map<number, string>> に代入でき、報告されているエラーが発生しなくなれば、Issue は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100