-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Control FlowThe issue relates to control flow analysisThe issue relates to control flow analysisEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this
Milestone
Description
TypeScript Version: nightly (2.1.0-dev.20160826)
Code
type Result = { success: true }
| { success: false, error: string }
function handleError(res: Result) {
if (res.success === true) {
return;
}
res.error; // OK
}
function handleError2(res: Result) {
if (res.success !== false) {
return;
}
res.error; // OK
}
function handleError3(res: Result) {
if (res.success) {
return;
}
res.error; // Property 'error' does not exist on type 'Result'
// but should be OK
}
Expected behavior:
All three cases should behave the same.
svr93, WiseBird, bradyasana, vultix, miso-belica and 5 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Control FlowThe issue relates to control flow analysisThe issue relates to control flow analysisEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this