2 ms·
To be fair, every reasonable linter will treat this as an error or at least a warning and inform the programmer about their blunder. In fact, in TypeScript you
by qayxc 4y ago
To be fair, every reasonable linter will treat this as an error or at least a warning and inform the programmer about their blunder. In fact, in TypeScript you don't even need a linter - the compiler itself can be configured to disallow fall-through cases. It's smart about it, too and still allows "empty" cases and makes the last case-statement optional, such that "switch (lorem) { case 'foo': case 'bar': ipsum(); break; case '...': blah(); } is still valid and compiles just fine even with noFallthroughCases configured.