- Error
- Reported by the binder
TS1210
Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
`eval` or `arguments` is declared or assigned inside a class. Class bodies are strict-mode code, which forbids this. Rename it.
What it means
Code in a class body (methods, constructors, accessors, field initialisers) always runs in strict mode, where eval and arguments can't be used as names for variables, parameters or functions.
Example
export class A {
m() {
var arguments = 1;
}
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(3,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
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
- Rename the binding, for example
args. - To collect all arguments, use a rest parameter:
m(...args: unknown[]).