--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.ts --- # Input ```ts switch (1) { case 1: enum E {} break; } switch (1) { default: enum E {} break; } switch (1) { case 1: interface I {} break; } switch (1) { default: interface I {} { } break; } switch (1) { case 1: type N = number; break; } switch (1) { default: type N = number; break; } ``` # Diagnostics ``` invalid.ts:3:3 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. 1 │ switch (1) { 2 │ case 1: > 3 │ enum E {} │ ^^^^^^^^^ 4 │ break; 5 │ } i The declaration is defined in this switch clause: 1 │ switch (1) { > 2 │ case 1: │ ^^^^^^^ > 3 │ enum E {} > 4 │ break; │ ^^^^^^ 5 │ } 6 │ i Unsafe fix: Wrap the declaration in a block. 1 1 │ switch (1) { 2 │ - → case·1: 2 │ + → case·1:·{ 3 3 │ enum E {} 4 4 │ break; 5 │ + → } 5 6 │ } 6 7 │ ``` ``` invalid.ts:9:3 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. 7 │ switch (1) { 8 │ default: > 9 │ enum E {} │ ^^^^^^^^^ 10 │ break; 11 │ } i The declaration is defined in this switch clause: 7 │ switch (1) { > 8 │ default: │ ^^^^^^^^ > 9 │ enum E {} > 10 │ break; │ ^^^^^^ 11 │ } 12 │ i Unsafe fix: Wrap the declaration in a block. 6 6 │ 7 7 │ switch (1) { 8 │ - → default: 8 │ + → default:·{ 9 9 │ enum E {} 10 10 │ break; 11 │ + → } 11 12 │ } 12 13 │ ``` ``` invalid.ts:15:3 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. 13 │ switch (1) { 14 │ case 1: > 15 │ interface I {} │ ^^^^^^^^^^^^^^ 16 │ break; 17 │ } i The declaration is defined in this switch clause: 13 │ switch (1) { > 14 │ case 1: │ ^^^^^^^ > 15 │ interface I {} > 16 │ break; │ ^^^^^^ 17 │ } 18 │ i Unsafe fix: Wrap the declaration in a block. 12 12 │ 13 13 │ switch (1) { 14 │ - → case·1: 14 │ + → case·1:·{ 15 15 │ interface I {} 16 16 │ break; 17 │ + → } 17 18 │ } 18 19 │ ``` ``` invalid.ts:21:3 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. 19 │ switch (1) { 20 │ default: > 21 │ interface I {} │ ^^^^^^^^^^^^^^ 22 │ { 23 │ } i The declaration is defined in this switch clause: 19 │ switch (1) { > 20 │ default: │ ^^^^^^^^ > 21 │ interface I {} > 22 │ { > 23 │ } > 24 │ break; │ ^^^^^^ 25 │ } 26 │ i Unsafe fix: Wrap the declaration in a block. 18 18 │ 19 19 │ switch (1) { 20 │ - → default: 20 │ + → default:·{ 21 21 │ interface I {} 22 22 │ { 23 23 │ } 24 24 │ break; 25 │ + → } 25 26 │ } 26 27 │ ``` ``` invalid.ts:29:3 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. 27 │ switch (1) { 28 │ case 1: > 29 │ type N = number; │ ^^^^^^^^^^^^^^^^ 30 │ break; 31 │ } i The declaration is defined in this switch clause: 27 │ switch (1) { > 28 │ case 1: │ ^^^^^^^ > 29 │ type N = number; > 30 │ break; │ ^^^^^^ 31 │ } 32 │ i Unsafe fix: Wrap the declaration in a block. 26 26 │ 27 27 │ switch (1) { 28 │ - → case·1: 28 │ + → case·1:·{ 29 29 │ type N = number; 30 30 │ break; 31 │ + → } 31 32 │ } 32 33 │ ``` ``` invalid.ts:35:3 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. 33 │ switch (1) { 34 │ default: > 35 │ type N = number; │ ^^^^^^^^^^^^^^^^ 36 │ break; 37 │ } i The declaration is defined in this switch clause: 33 │ switch (1) { > 34 │ default: │ ^^^^^^^^ > 35 │ type N = number; > 36 │ break; │ ^^^^^^ 37 │ } 38 │ i Unsafe fix: Wrap the declaration in a block. 32 32 │ 33 33 │ switch (1) { 34 │ - → default: 34 │ + → default:·{ 35 35 │ type N = number; 36 36 │ break; 37 │ + → } 37 38 │ } 38 39 │ ```