- Error
- Reported by the binder
TS7028
Unused label.
A statement label is declared but no `break` or `continue` uses it. Remove the label.
What it means
A label such as outer: is only useful as the target of break outer or continue outer. This is reported when allowUnusedLabels is false; it often catches an object literal written where a block was parsed ({ a: 1 } as a statement makes a a label).
Example
{
"compilerOptions": {
"strict": true,
"target": "es2022",
"module": "esnext",
"moduleResolution": "bundler",
"noEmit": true,
"allowUnusedLabels": false
}
}
export function f(xs: number[]) {
outer: for (const x of xs) {
console.log(x);
}
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(2,3): error TS7028: Unused label.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01.
How to fix
- Remove the label.
- If you meant an object literal, wrap it in parentheses or assign it to something.