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
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'."
TypeScript Version:** 2.8.1 and 2.9.0-dev.20180409
nested switch undefined, strictnullcheck
Code
(with strictnullchecks activated)
Also note that this typechecks:
Expected behavior:
Should compile fine
Actual behavior:
Errors with "Function lacks ending return statement and return type does not include 'undefined'."
Playground Link:
http://www.typescriptlang.org/play/#src=const%20foo%20%3D%20(a%3A%201%20%7C%202%20%7C%203)%3A%20'a'%20%7C%20'b'%20%7C%20'c'%20%3D%3E%20%7B%0D%0A%20%20switch%20(a)%20%7B%0D%0A%20%20%20%20case%201%3A%0D%0A%20%20%20%20%20%20return%20'a'%0D%0A%20%20%20%20default%3A%0D%0A%20%20%20%20%20%20switch%20(a)%20%7B%0D%0A%20%20%20%20%20%20%20%20case%202%3A%0D%0A%20%20%20%20%20%20%20%20%20%20return%20'b'%0D%0A%20%20%20%20%20%20%20%20case%203%3A%0D%0A%20%20%20%20%20%20%20%20%20%20return%20'c'%0D%0A%20%20%20%20%20%20%7D%0D%0A%20%20%7D%0D%0A%7D%0D%0A
Related Issues:
The text was updated successfully, but these errors were encountered: