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
This is a design limitation for the current implementation. the control flow graph is setup at an earlier stage of compilation, where types are not known; so a switch statement is considered exhaustive iff it has a default label and none of the next statement is not reachable for any of the labels (e.g. all have a return statement). When types are known later on, the checker chooses not to show the error for some switch statements if it can assert that they handle all possible types in the union. this is a rather limited set, e.g. single switch at the end of the function, but does not work with more complicated control flow graphs. this is why the error is not reported on the top one but on the nested one.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.7.0-dev.20171202
Code
run with
tsc --strict
Expected behavior:
Shape has two kinds only, there is no error with
withoutDefault
.Actual behavior:
error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
The text was updated successfully, but these errors were encountered: