Hacker News new | ask | show | jobs
by elyseum 1888 days ago
No need to ‘return’ when you throw an error, but your approach is valid IMO: if structure / readability is that important, refactor the switch to it’s own method with only if checks in it. Hard to make that simpler and more readable.
1 comments

If you don't have a 'return' there's nothing to say that some time later some junior developer would not modify throw to be something else or forget that throw does not return.
This will prevent the JR dev from making that mistake: https://eslint.org/docs/rules/no-fallthrough
That's what tests are for.