• Error
  • Reported by the type checker

TS2561

Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?

An object literal has a property the target type doesn't declare, and a similar name exists. Usually a typo: use the suggested name.

What it means

This is the excess property check (TS2353) with a suggestion: the object literal has a property that the target type doesn't have, and a property with a close spelling exists.

Example

index.ts
interface User {
  firstName: string;
}
export const u: User = { firstname: "Ada" };
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(4,26): error TS2561: Object literal may only specify known properties, but 'firstname' does not exist in type 'User'. Did you mean to write 'firstName'?

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

  • Use the suggested property name.
  • If the property should be allowed, add it to the type.