- Error
- Reported by the lexer and parser
TS1181
Array element destructuring pattern expected.
An array destructuring pattern contains something that cannot be a binding target, such as a reserved word.
What it means
Each element of an array destructuring pattern must be a name, a nested pattern, a hole (,) or a ...rest element. A reserved word such as debugger or if ends the pattern here, so other syntax errors usually follow.
Example
const [debugger] = [1];
export {};
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,8): error TS1181: Array element destructuring pattern expected.
index.ts(1,16): error TS1005: ';' expected.
index.ts(1,18): 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
- Use a valid variable name in the pattern:
const [first] = [1];.