microsoft / microsoft/TypeScript
Flow analysis doesn't work with es6 collections 'has' method
未關閉
還沒有人認領這個 Issue。
Awaiting More Feedback
Suggestion
- 主要語言
- Go
- 星號
- 111k
- 分支
- 14.3k
- 平均合併
- 2 天 4 小時
- 30 天內合併 PR
- 132
描述
TypeScript Version: 2.1.1
Code
const x = new Map<string, string>();
x.set("key", "value");
if (x.has("key")) {
const y : string = x.get("key"); // error: y is string | undefined, not string
}
Expected behavior:
y is narrowed down to string
Actual behavior:
y is still string | undefined even after checking if the map has that key
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先重現提供的、使用 Map.has 和 Map.get 的 TypeScript 2.1.1 範例,然後追蹤編譯器針對 ES6 集合方法的控制流程分析。完成的標準是:get 回傳的值在 has 檢查內部被縮小為 string,同時不破壞相關的縮小行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- typescript
- 領域
- compilers
- Issue 類型
- 缺陷
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 32/100