allowUnusedLabels — TypeScript compiler option
Controls diagnostics for labels that are never targeted by a break or continue. With false they are compiler errors; true permits them. Omission leaves suggestion-level reporting to editors. A label is a statement construct, not a property or a variable. Default: omitted: editor suggestion rather than compiler error; false: error; true: suppress the diagnostic. With the enforcing setting, the corrected example compiles; the comparison fixture triggers TS7028. Disabling this particular check accepts the comparison fixture. Observed corrected runtime output: 'ready'. 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
{ "compilerOptions": { "allowUnusedLabels": false }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| allowUnusedLabels | boolean | Set explicitly to true or false; omission uses the default described above. |
Working Example
// File: tsconfig.json (JSON; omit this file-label comment){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "types": [], "noEmitOnError": true, "strict": true, "allowUnusedLabels": false }, "files": [ "example.ts" ]}// File: example.tsouter: { console.log("ready"); break outer; }