TS2339
TypeScriptERRORNotableType SystemHIGH confidence

Property does not exist on type

What this means

A property is being accessed that does not exist on the object's type.

Why it happens
  1. 1A typo in the property name.
  2. 2The object has a different shape than expected.
  3. 3Working with an object of type 'any' that was later assigned a more specific type.
How to reproduce

Accessing a non-existent property on a typed object.

trigger — this will error
trigger — this will error
interface Person {
  name: string;
}
const person: Person = { name: "John Doe" };
console.log(person.age);

expected output

error TS2339: Property 'age' does not exist on type 'Person'.

Fix 1

Correct the property name

WHEN The property name is misspelled.

Correct the property name
interface Person {
  name: string;
}
const person: Person = { name: "John Doe" };
console.log(person.name);

Why this works

Using the correct property name that is defined on the type.

Fix 2

Add the property to the interface

WHEN The property is missing from the type definition.

Add the property to the interface
interface Person {
  name: string;
  age: number;
}
const person: Person = { name: "John Doe", age: 30 };
console.log(person.age);

Why this works

Updating the type definition to include the property being accessed.

What not to do

Cast the object to 'any' before accessing the property

This disables type checking and hides potential bugs.

Sources
Official documentation ↗

microsoft/TypeScript src/compiler/diagnosticMessages.json

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All TypeScript errors