• Error
  • Reported by the lexer and parser

TS1003

Identifier expected.

The parser expected a name (an identifier) here but found something else, such as a punctuation mark or the end of the statement.

What it means

A name is required at this point: after a . in a property access, after keywords such as class or function in a declaration, or in a parameter or variable list. Often the code is unfinished, or a reserved word or symbol is in the place of the name.

Example

index.ts
const obj = { a: 1 };
const v = obj.;
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(2,15): error TS1003: Identifier 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

  • Finish the expression or declaration with a name: obj.a.
  • If the name is a reserved word, rename it, or use bracket access (obj["default"]).
  • Remove a stray . or , left over from an edit.