You can create scope blocks around your cases, and the compiler will be happy:
switch (1) {
case 1: {
// notice these extra curly braces
const foo = 1;
break;
}
case 2: {
const foo = 2;
break;
}
}
Read the answer from Igor if you need more context.