• Error
  • Reported by the binder

TS1119

An object literal cannot have property and accessor with the same name.

An object literal has both a plain property and a getter or setter with the same name. Use one form.

What it means

A name in an object literal is either a data property (a: 1) or an accessor (get a() {} / set a(v) {}), not both.

Example

index.ts
const o = {
  a: 1,
  get a() { return 2; },
};
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(3,7): error TS1119: An object literal cannot have property and accessor with the same name.

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

  • Keep either the property or the accessor.
  • If the accessor needs a backing value, store it under another name: _a: 1, get a() { return this._a; }.