-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Switch on enum of one member not considered exhaustive #12771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is it possible to get information where error occurred? Right now there is no file, line information about that. |
I have a related issue also with enums with one value, you can directly copy this to the microsoft typescript playground: No error as expected for this snippet (2 values in enum) enum Rating {
Like = 1,
Dislike
};
let a: Rating;
switch (a) {
case Rating.Like:
break;
case Rating.Dislike:
break;
default:
let s: never = a;
} On the other hand, drop it down to one value in the enum and you get the error:
enum Rating {
Like = 1
};
let a: Rating;
switch (a) {
case Rating.Like:
break;
default:
let s: never = a; // error here
} |
Examples in this issue seems to be working as expected in latest. |
TypeScript Version: 2.1.4
Code:
Expected behaviour (as far as I know):
Compiles without error
Actual behaviour:
Function
g
does not compile, with errorTS2366: Function lacks ending return statement and return type does not include 'undefined'.
.Without strict null checks, it compiles without error.
The text was updated successfully, but these errors were encountered: