I'm trying to learn TypeScript and had been following online tutorial examples for enum support in TypeScript. For this below snippet:
enum daysoftheweek{
SUN, MON, TUE, WED, THU, FRI, SAT
}
let day:daysoftheweek ;
day = daysoftheweek.FRI; //line 7
if (day === daysoftheweek.MON){
console.log("got to go to work early");
}else{
console.log("I may go late");
}
...I'm getting this error at compile time and I don't understand why:
TS2367: This condition will always return 'false' since the types 'daysoftheweek.FRI' and 'daysoftheweek.MON' have no overlap.
If I modify line 7 to this, the error goes off:
day = daysoftheweek.MON;
Can somebody please explain why compilation is throwing that error?
(I followed other threads on this "have no overlap" error , but couldn't understand the reason for this particular snippet's problem)