- I've enabled the
noFallthroughCasesInSwitchoption in the tsconfig.json file. - That option warned me about an "error", and I want to let the Typescript compiler know it's intentional.
- It's not documented, and the online examples don't work for me - how can I mark it as intentional?
function getRandomInt(max: number) {
return Math.floor(Math.random() * max);
}
switch(getRandomInt(3)) {
/* falls through */
/* fall through */
/* FALLTHROUGH */
case 1: /* falls through */ /* fall through */ /* FALLTHROUGH */ /* <----- Still getting an error here "Fallthrough case in switch. (7029)" */
/* falls through */
/* fall through */
/* FALLTHROUGH */
console.log(1);
/* falls through */
/* fall through */
/* FALLTHROUGH */
case 2:
console.log(2);
break;
}
The error can be seen in this link as well: link.
But there's a bug in TS Playground, so you must manually click the "TS Config" menu and then Tick the noFallthroughCasesInSwitch option so it will be turned on, otherwise, you'll not see the error.