-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed

Description
TypeScript Version: nightly (2.1.0-dev.20161012)
Code
enum E { A, B }
function f(e: E): number {
switch (e) {
case E.A: return 0
case E.B: return 1
}
}
function g(e: E): number {
if (!true)
return -1
else
switch (e) {
case E.A: return 0
case E.B: return 1
}
}
Expected behavior:
Both functions succeed.
Actual behavior:
a.ts(10,19): error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
If I remove the else
keyword (which makes an equivalent program), it compiles without errors.
If I put an e
access under the switch
, I see (parameter) e: never
on hover, so that part is working.
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed