Skip to content

Property 'X' does not exist on type 'Y'

Error message

                Property does not exist on type
              

Quick summary

You tried to access a property that TypeScript doesn't know about on the given type. The property is not declared in the interface or type.

Why this happens

  • Typo in the property name

  • The property exists at runtime but isn't declared in the type

  • Accessing a property from the wrong branch of a union type

  • The interface is missing a property that the object actually has

Minimal example

✗ Broken code
interface User { name: string; }
const user: User = { name: "Alice" };
console.log(user.nmae); // typo
✓ Fixed code
interface User { name: string; }
const user: User = { name: "Alice" };
console.log(user.name);

Fix the typo: 'nmae' should be 'name'.

How to diagnose

  • Check the spelling of the property name

  • Verify the property is declared in the interface/type

  • If using a union type, narrow it before accessing type-specific properties

  • Check if the property is optional and might be undefined

How to fix

  • Fix the typo in the property name

  • Add the missing property to the interface/type definition

  • Use a type assertion if you know the property exists at runtime

  • Narrow the union type with a type guard before accessing the property

How to prevent

  • Keep interfaces in sync with actual object shapes

  • Use strict mode to catch missing properties

  • Consider using Record<string, unknown> for dynamic objects

Related Resources

Related Glossary

← Back to language