You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nested Switch infers additional undefined on return type. #23281
TypeScript Version:** 2.8.1 and 2.9.0-dev.20180409
nested switch undefined, strictnullcheck
Code
(with strictnullchecks activated)
constfoo=(a: 1|2|3): 'a'|'b'|'c'=>{// <- Errors here with: Function lacks ending return statement and return type does not include 'undefined'.switch(a){case1:
return'a'default:
switch(a){case2:
return'b'case3:
return'c'}}}
Also note that this typechecks:
constfoo=(a: 1|2|3): 'a'|'b'|'c'=>{// No errorswitch(a){case1:
return'a'default:
return(()=>{switch(a){case2:
return'b'case3:
return'c'}})()}}
Expected behavior:
Should compile fine
Actual behavior:
Errors with "Function lacks ending return statement and return type does not include 'undefined'."
Activity
sledorze commentedon Apr 10, 2018
Ok duplicate of #11572