While doing a Lynda tutorial on Typescript ( https://www.lynda.com/Visual-Studio-tutorials/TypeScript-types-part-2/543000/565613-4.html#tab ), I hit a snag. The sample code illustrates how switch statements work in TypeScript but the code that seems to work fine for the instructor throws a Type 'x' is not comparable to type 'y' error. Here's the code:
enum temperature{
cold,
hot
}
let temp = temperature.cold;
switch (temp) {
case temperature.cold:
console.log("Brrr....");
break;
case temperature.hot:
console.log("Yikes...")
break;
}
I get an error and squiggles under case temperature.hot: saying:
Type 'temperature.hot' is not comparable to type 'temperature.cold'
What gives?