• Error
  • Reported by the binder

TS1213

Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode.

A word reserved in strict mode (such as `private` or `static`) is used as a name inside a class. Classes are always strict. Rename it.

What it means

Class bodies are always strict-mode code, so the strict-mode reserved words (implements, interface, let, package, private, protected, public, static, yield) can't be used as names of variables or parameters inside them.

Example

index.ts
class A {
  m() {
    let private = 1;
  }
}
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(3,9): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in 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 variable or parameter, for example isPrivate.