• Error
  • Reported by the lexer and parser

TS1359

Identifier expected. '{0}' is a reserved word that cannot be used here.

A reserved word such as `class` or `function` is used as a name. Choose a different name.

What it means

Reserved words (break, class, const, function, new, return and so on) can't be used as variable, function, parameter or class names in any mode.

Example

index.ts
export function format(null) {}
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,24): error TS1359: Identifier expected. 'null' is a reserved word that cannot be used here.

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 it, for example className or klass instead of class, value instead of null.
  • Reserved words are fine as property names: obj.class and { class: 1 } work.