microsoft / microsoft/TypeScript
Type narrowing based on iterator `done` value?
オープン
@rbuckton がすでに取り組んでいます。
2019年6月26日 から。
Needs Investigation
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
interface MyIterator<T> {
next():
| {
done: false;
value: T;
}
| {
done: true;
value: undefined;
};
[Symbol.iterator](): MyIterator<T>;
}
interface Item { name: string }
function m(iter: MyIterator<Item>) {
for (const it of iter) {
console.log(it.name); // Error here complaining about 'it': Object is possibly 'undefined'.ts(2532)
}
}
Expected behavior:
Actual behavior:
Related Issues:
https://github.com/microsoft/TypeScript/issues/11450 seems related. but here even with --strictNullChecks same error is reported here.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。