TypeScript Compiler Options

noFallthroughCasesInSwitch — TypeScript compiler option

Reports non-empty switch cases that can continue into the next case without an explicit control-flow exit. Empty grouped cases remain valid. Use break, return or throw where appropriate; the option does not replace exhaustiveness checking. Default: false in 5.8.3, including with strict enabled. With the enforcing setting, the corrected example compiles; the comparison fixture triggers TS7029. Disabling this particular check accepts the comparison fixture. Observed corrected runtime output: 'one'. Use two separate files as labeled, then run tsc -p tsconfig.json and node example.js in an isolated directory. Tested with TypeScript 5.8.3 and Node.js 22.16.0; not a single-file live editor example.

Formal Syntax & Structure

typescript syntaxtypescript
{  "compilerOptions": {    "noFallthroughCasesInSwitch": true  }}

Parameters & Attributes

NameTypeDescription
noFallthroughCasesInSwitchbooleanSet explicitly to true or false; omission uses the default described above.

Working Example

Example Snippettypescript
// File: tsconfig.json (JSON; omit this file-label comment){  "compilerOptions": {    "target": "ES2022",    "module": "CommonJS",    "types": [],    "noEmitOnError": true,    "strict": true,    "noFallthroughCasesInSwitch": true  },  "files": [    "example.ts"  ]}// File: example.tsfunction choose(n: number) { switch (n) { case 1: console.log("one"); break; case 2: console.log("two"); break; } }choose(1);
TypeScript Reference