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
Problem with exhaustiveness check for tagged unions #20409
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.
Activity
mhegazy commentedon Dec 2, 2017
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
defaultlabel and none of the next statement is not reachable for any of the labels (e.g. all have areturnstatement). 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. singleswitchat 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.dhcmrlchtdj commentedon Dec 3, 2017
Thanks for you reply.
typescript-bot commentedon Jan 2, 2018
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.