3.2.0
1.8.10
function foo (a: number, b: number): number {
switch (a) {
case 1:
switch (b) {
case 2:
return 1;
default:
return 2;
}
default:
return 3;
}
}
使用tslint.json
配置:
(include if relevant)
在外循环的默认情况之前的行抛出 no-switch-case-fall-through。
没有错误。
同为
function(a: number, b:number): void {
switch (a) {
case 1:
if (b > 10) {
return;
} else {
return;
}
case 2:
return;
default:
return;
}
}
它甚至不需要嵌套来抛出。
function(a: number, b:number): void {
switch (a) {
case 1: {
return;
} // Throws
case 2:
return;
default:
return;
}
}
此处相同 - no-switch-case-fall-through
无法识别break/return
内部 case 块case ... { ... }
。
最有用的评论
它甚至不需要嵌套来抛出。