- Error
- Reported by the lexer and parser
TS1128
Declaration or statement expected.
The parser expected the start of a declaration or statement but found something else, often an extra closing brace.
What it means
At the top level of a file or a block, each item must be a statement or declaration. This is reported when a token can't start one, most often a } with no matching {, or leftover text after an edit.
Example
export function f() {}
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(2,1): error TS1128: Declaration or statement expected.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Remove the extra
}or other stray text. - Check that braces above the reported line are balanced.